I have a simple component that maintains an internal state. I have another component that toggles whether or not <
If you want to be able to unmount and mount while maintaining state, you will need to store the count in App and pass down the count via props.
(When doing this, you should be calling a toggle function inside of App, you want the functionality which changes data to live with the data).
I will modify your fiddle to be functional and update my answer with it.