cultureamp / react-elm-components

Write React components in Elm
https://www.npmjs.com/package/react-elm-components
BSD 3-Clause "New" or "Revised" License
779 stars 54 forks source link

Add null check to prevent error when unmounting #5

Closed ghost closed 7 years ago

ghost commented 7 years ago

As pointed out in #3, React calls the ref with null when a component unmounts:

React will call the ref callback with the DOM element when the component mounts, and call it with null when it unmounts.

This causes react-elm-components to break, since it will try to mount the app on the node provided by the callback.

This PR fixes that by adding a simple null check.

rtfeldman commented 7 years ago

Got it, thanks @MoeSattler!