Hacker News new | ask | show | jobs
by globuous 3966 days ago
The virtual DOM is sick on ReactJS. However, I ran into quite a bit of trouble when I used Semantic UI + Reactjs for implementing a modal window. Because React works with the virtual DOM, you're not supposed to modify the DOM directly or else React loses track of what's going on. So when I implemented my Semantic UI modal, I would get DOM errors and my application would freeze. What would happen is that Semantic UI's modal changes the DOM directly when you open and close the modal (as in, without going through React's virtual DOM), which makes the whole application unusable.

I guess all I'm trying to say is that yes, React's virtual DOM has its pros, but it will occasionally also have cons (like when you use a third party .js that modifies the DOM directly).

I'm new to React though (two weeks). So there may be well known work arounds for this 'problem'. Since I do not know of any, if anyone does, please share ! :)

1 comments

There's a react module for modals :) https://github.com/rackt/react-modal

But yeah, in a similar fashion to angular, modifying the DOM outside the 'blessed' render()ing is a pathway to darkness. You can do a bit of fiddling in the lifecycle though - take a look at https://facebook.github.io/react/docs/component-specs.html#u...