MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / Navigation

Class Navigation

code/composition/src/Navigation.jsx:4–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import PropTypes from 'prop-types';
3
4export 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
38Navigation.propTypes = {
39 track: PropTypes.func

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected