jeudi 31 mars 2016

Controlling React component props from DOM

I have a React modal I created which has two props: isOpened and onClose. This works fine from within React, however my whole site isn't completely React yet and so I want to be able to control my modal from outside of the React environment.

I have set isOpened to a window variable, and onClose to a window function that updates this variable, and this works fine on first load, but of course when these variables are updated my modal component is not re-rendered.

Is there a way to call forceUpdate from the DOM when I update my variable? Or am I going about this in completely the wrong way?

FYI: I am happy for a hacky solution as this is temporary until I can finish moving my site to React.

Thanks!




Aucun commentaire:

Enregistrer un commentaire