Skip to content

Tag: reactjs

Get viewport/window height in ReactJS

How do I get the viewport height in ReactJS? In normal JavaScript I use but using ReactJS, I’m not sure how to get this information. My understanding is that only works for components created. However this is not the case for the document or body element, which could give me height of the window. Answer…

ReactJS – prevent re-render children

I have parent React component with 3 children, like this: I am trying to be able to change children’s position based on current parent state. So in different cases I need to return C1,C3,C2 or C3,C2,C1, etc. But I want to this without re-render the children. I am trying to use shouldComponentUpdate on e…

ReactJS: setTimeout() not working?

Having this code in mind: Isn’t the state supposed to change only after 3 seconds? It’s changing immediately. My main goal here is to change the state every 3 seconds (with setInterval()), but since it was not working, I tried setTimeout(), which is not working either. Any lights on this? Thanks! …