3 ms·
let's just make a wrapper :D
by zackify 11y ago
let's just make a wrapper :D
- lobster_johnson 11y agoReact generally requires more than just a wrapper, since its virtual DOM is populated in a highly controlled manner that libraries need to follow. But you can try.
- btown 11y agoActually it's pretty trivial. You can always just have your render function be just a static div, set a ref to the div, and do setup in componentDidMount and updates in componentWillUpdate. Since the render function will always return a trivially identical subtree, it will never change that DOM node. Of course, if your component moves in the HTML hierarchy, your animation may restart, but that's unlikely in most use cases.
- lobster_johnson 11y agoDepends. Animation tends to be about transitions, so you want to transition between elements. For that you need to handle the virtual DOM. Twitter's Velocity [1] wrapper is an example of something that works like this, though the authors admit their solution is not idiomatic React. [1] https://github.com/twitter-fabric/velocity-react#readme https://github.com/twitter-fabric/velocity-react#readme