Last active
March 16, 2016 04:43
-
-
Save roman01la/ca29d6e2ad80a6a92864 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Nav extends React.Component { | |
constructor() { | |
super(); | |
this.onNav = this.onNav.bind(this); | |
} | |
onNav(idx) { | |
// do something with `this` and `idx` | |
} | |
render() { | |
return ( | |
<ul> | |
{btns.map((btn, i) => <Button key={btn} onClick={this.onNav} idx={i}>{btn}</Button>)} | |
</ul> | |
); | |
} | |
} | |
class Button extends React.Component { | |
shouldComponentUpdate(nextProps) { | |
return !shallowEqual(nextProps, this.props); | |
} | |
render() { | |
const { onClick, idx, children } = this.props; | |
return <button onClick={() => onClick(idx)}>{children}</button>; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@adaniliuk I believe so in this case. You aren't creating a new function.