#54 Using Anchor tags instead of SourceLink Component (Making sourceLink not very reusable).
Closed: Fixed 2 years ago by lbrabec. Opened 3 years ago by queeniva.

noticed that a Sourcelink component has been declared, but in most places, an anchor tag is still been used instead of the source link component... not following React component architecture.

//current code with class component

import React, {Component} from 'react'

class SourceLink extends Component {
render() {
    return (
        <a
            target="_blank"
            rel="noopener noreferrer"
            href={this.props.href}
            className="smallsuper">
            <i className="fas fa-external-link-alt"></i>
        </a>
    )
 }
}

 export default SourceLink

//Improvement with functional component

import React from 'react'

const SourceLink = ({ href, className, linkName, onClick, role, icon }) => {

return (
    <a
        target="_blank"
        rel="noopener noreferrer"
        href={href}
        className={className}
        onClick={onClick}
        role={role}
    >
        {icon && <i className="fas fa-external-link-alt" />}
        {linkName}
    </a>

)

}

export default SourceLink

Metadata Update from @lbrabec:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

2 years ago

Login to comment on this ticket.

Metadata