react-bodymovin icon indicating copy to clipboard operation
react-bodymovin copied to clipboard

add universal "support" (serverside rendering)

Open acidicX opened this issue 6 years ago • 4 comments

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.

acidicX avatar Aug 17 '17 14:08 acidicX

Just tested and it works, cheers!

fsegouin avatar Aug 21 '17 13:08 fsegouin

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 avatar Aug 21 '17 13:08 Olical

@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.

acidicX avatar Aug 21 '17 13:08 acidicX

Fix merged into https://github.com/Olical/react-bodymovin

Olical avatar Oct 03 '17 11:10 Olical