react-bodymovin
react-bodymovin copied to clipboard
add universal "support" (serverside rendering)
When you use react-bodymovin in a universal react app with serverside rendering, the app will currently crash. This is related to https://github.com/bodymovin/bodymovin/issues/440.
I think it would be good to catch this already in react-bodymovin
, because I'm pretty sure the react component would break if this switch is included in bodymovin
. Obviously, bodymovin will not work without a dom, but by catching it you can just ~~return an empty component~~ decide to not animate on didMount, which will not break the whole app.
I added a PR with the solution in place. The isDOM detection is used by us for almost all projects, should be no issue even with older browsers.
Just tested and it works, cheers!
Oh, nice. I'll take a look at this soon. I no longer work at Qubit so I'll try to sort this out tonight. I'll update your PR with https://standardjs.com/ too, I should've put it in the README or something really, just forgot. Unless you'd like to do it 😄
Thanks for the fix though!
@Olical Thanks! PR updated to standard
. I also removed the conditional in render()
, which was unnecessary and might have lead to client-side tree rehydration breaking.
Fix merged into https://github.com/Olical/react-bodymovin