I'm trying to make a simple transition with react on a button click where the body max-height goes to 0 on componentWill update, then back to 500px or 100% on componentDidUpdate. I haven't been abe to quite understand it from the other questions I've seen so could someone show me an example with an explanation of how it works?
I also wouldn't mind an example/explanation using reactcsstransitiongroup.
More Info
I understand that transitionend attaches an event listener but what I'm getting confused with is how to use that to ensure the component doesn't update until the transition is finished (I've taught myself react and pretty much all my coding knowledge so I don't know if this is suppossed to be hard to understand, but its hard for me at the moment). Thanks all!
So after some rest I decided it was time for another chapter of 'Student teaches Student' (written directed and starring me).
To anwer my own question more succintly, the transitionend event listener attaches a listener to an element and fires a callback function whenever the transition is over. The problem I was having was that this is async and thus, putting it in componentWillUpdate wouldn't work as the DOM would render before the transition had completed. My current workaround is to have the button click call for a function that contains the event listener, and having the callback function of trnasitionend change the state of the component. This way no rendering is done until the transition is complete.
Code:
codepen (check the codepen