Last active
January 27, 2019 08:20
-
-
Save rao123dk/9ba0b67ff4a8cb34841b4ba5e9fb6ee9 to your computer and use it in GitHub Desktop.
This file contains 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
//Util.js | |
export function reactBind(data,that){ | |
return data.forEach((fn) => that[fn] = that[fn].bind(that)); | |
} | |
//myNewComponet.jsx | |
import reactBind from './Util.js'; | |
class myNewComponet extends React.Component{ | |
constructor(props) { | |
super(props); | |
// Not this | |
//this.onChange = this.onChange.bind(this); | |
reactBind(['onChange','onItemClick','onListClick'], this); // OK | |
} | |
/* | |
rest code | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment