Question: I'm calling a function in React within componentDidMount that queries the DOM however the DOM isn't rendered in time even though i'm calling it after componentDidMount.

The strange thing is that in webpack it all works fine and the DOM is rendered and ready for my querySelectorAll. However when built it isn't. I've tried on multiple server types and its always the same.

My initial thoughts are that minifying the code is messing it up somehow.

I only require the function to run once so that's why i placed it in component did mount

Answer: 
As explained in [this answer](https://stackoverflow.com/a/36056794/242365), `componentDidMount` is called after all the children components have been mounted, but before any parent components have been mounted.

For me it worked to delay my code using `setTimeout()` (with 0 ms delay) from within `componentDidMount`.
`componentDidMount` is only called once in the lifecycle of any component, render againt will not reinitialize the component. 
Have you ever try with `componentDidUpdate`. This hit when component is updated.