Closed inomdzhon closed 7 years ago
@Kepro Thanks. I had read this article long time ago.
I prefer JS animation, than CSS animation. For this reason I use and like GSAP library.
Anyway, author by article recommend use addons (ReactCSSTransitionGroup
), but I would like "native" realisation, I mean lifecycle method.
It could also work with Promises – if React's componentWillUnmount
supported a promise as a return type that would tell it if/when to wait, and resolve unmounting after the promise has resolved, here's a proof of concept in action https://dio.js.org/api.html#animations
Making unmounting controllable by the component is not likely to be an feature in the near future. There are a bunch of reasources and options tho for dealing with this limitation though. react-transition-group v2 has a few lower level components that help manage this (specifically the Transition
component) and can used for doing animation with other libraries like greensock
React - good the templating engine, but making animation sometime very horrible.
I use GreenSock animation library for animation, since react animation library like
react-motion
not impressed me for solve design task.I haven't problem when I need animation after
componentDidMount
, unlike animation beforecomponentWillUnmount
.I have to apply the "hack" for last situation, example wrapping my component to
TransitionGroup
(react-transition-group
), it's extends react lifecycle (componentWillLeave([callback])
), or another "hack".And in general what I want to ask.
It's possible to add callback for lifecycle
componentWillUnmount
?Or how I can easily animate my components?