flux-react-router-example icon indicating copy to clipboard operation
flux-react-router-example copied to clipboard

componentDidMount vs. componentWillMount

Open dpwrussell opened this issue 8 years ago • 1 comments

Hey,

Thanks for creating an actual flux application which actually does something real with AJAX, the official documentation in this area is lacking in the extreme.

The docs specify that AJAX requests should be conducted in componentDidMount, not in componentWillMount. I'm curious why you've done it there instead?

All the flux examples I've seen have the subscription happening in componentWillMount.

I saw issue #23, but it didn't really make it clear to me why the switch was made. It looked to me like the double rendering was being caused by the component rendering with whatever blank initial state was specified and then rendered again as soon as the server responded with the real content, which updated the store, which caused it to rerender? That's a pattern I've seen a lot with React with and without Flux in my limited exposure so far, it seems perfectly normal.

Thanks for your time.

dpwrussell avatar Dec 09 '15 21:12 dpwrussell

I ended up with the same exact question. The issue is half a year old, so I'll try to bump it. @gaearon can you please answer this one?

igor10k avatar Jun 01 '16 17:06 igor10k