Is there a good way to use private variables and methods in React.js
If you are using es7, you can define class properties as a private variables like this:
1 2 3 4 5 6 7 8 9 10 11 | class Hello extends React.Component { name = 'Jack'; render() { return ( <div> {this.name} </div> ); } } export default Hello; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.