Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
vicary4785y@C0D4 hmm... that makes the idea way more clearer.
React's render cycle and state update batching, by nature, schedules things to at least 1 tick away. That may confuses those thinking "before" as a synchronous before.
So it should be "before" if it happens in the same tick, otherwise use "will".
A good way to imply the possibility of cancellable events too. -
hitko31455y"On will unmount" could always be just "on unmount", since it doesn't affect the component being unmounted, it's just a way to clenup things during that process.
"On before unmount" on the other hand signifies the main proccess didn't start yet (unmounting has been requested and approved by preflight checks, but no action regarding unmounting the component has been taken, and there may still be a way to interrupt the process). -
vicary4785yTo put it another way, a cancellable onChange is fired before internal state is changed.
So for the special kind of event handlers that runs before an event, would you prefer the react style "will" as in "onWillChange", or the W3C style "before" as in "onbeforeunload"?
question
javascript
react