If you want to hide/show components without losing their internal state in ReactJS? One option would be to move the conditional inside the component itself:
1 2 3 4 5 6 7 8 9 10 11 | Bio = React.createClass({ render: function() { if(this.props.show) { return <p>bio comp</p> } else { return null; } } }); <Bio show={isBioPage} /> |
Whether this is “best practise” or not probably depends on the exact situation.
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.