gaearon / gaearon/flux-react-router-example

componentDidMount vs. componentWillMount

Open
#45 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.4k
Forks
171
PR merge metrics
No merged PRs in 30d

Description

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](https://facebook.github.io/react/docs/component-specs.html#mounting-componentwillmount) 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.