| 2 | import PropTypes from 'prop-types'; |
| 3 | |
| 4 | export default class Navigation extends React.Component { |
| 5 | constructor(props) { |
| 6 | super(props); |
| 7 | |
| 8 | this.links = [ |
| 9 | 'About', 'Products', 'Contacts' |
| 10 | ]; |
| 11 | } |
| 12 | render() { |
| 13 | return ( |
| 14 | <nav> |
| 15 | <ul> |
| 16 | { this.links.map( |
| 17 | (label, index) => { |
| 18 | let onClickHandler = this._onLinkClicked.bind(this, index); |
| 19 | |
| 20 | return ( |
| 21 | <li key={ index }> |
| 22 | <a onClick={ onClickHandler }> |
| 23 | { label } |
| 24 | </a> |
| 25 | </li> |
| 26 | ); |
| 27 | } |
| 28 | ) } |
| 29 | </ul> |
| 30 | </nav> |
| 31 | ); |
| 32 | } |
| 33 | _onLinkClicked(index) { |
| 34 | this.props.track && this.props.track(`${ this.links[index] }-clicked`); |
| 35 | } |
| 36 | }; |
| 37 | |
| 38 | Navigation.propTypes = { |
| 39 | track: PropTypes.func |
nothing calls this directly
no outgoing calls
no test coverage detected