I'm integrating MatterJs into a react application that I've developed. I just ran into issue #226 . Since react first modifies its virtual dom before it updates the actual dom, the dom element doesn't exist when the engine is created, so an error is thrown. If I initialize the engine without providing an element, I get a warning and am unable to add the element later.
What is the best way to get around this currently? Is there some way to initialize the engine without an element but then add one after the dom has been updated? I've tried the following:
It seems to be ignored even though inspecting the engine object shows that it has been set properly. I could initialize the engine after the dom has been updated, but this breaks my component hierarchy since child components add bodies to the world.
I'm integrating MatterJs into a react application that I've developed. I just ran into issue #226 . Since react first modifies its virtual dom before it updates the actual dom, the dom element doesn't exist when the engine is created, so an error is thrown. If I initialize the engine without providing an element, I get a warning and am unable to add the element later.
What is the best way to get around this currently? Is there some way to initialize the engine without an element but then add one after the dom has been updated? I've tried the following:
this.engine.render.canvas = document.getElementById('projectEngine');
It seems to be ignored even though inspecting the engine object shows that it has been set properly. I could initialize the engine after the dom has been updated, but this breaks my component hierarchy since child components add bodies to the world.