Skip to content

Conversation

FredericHeem
Copy link

@FredericHeem FredericHeem commented May 29, 2016

This PR adds routes and params to the location object, these 2 pieces of data are then later used by a redux middleware to find out the component that has been mounted, this middleware then calls a rest api to retrieves the data.
The idea behind the pattern is to decouple a component lifecycle to retrieving its data. componentWillMount no longer initiates the retrieval of its data.
As a consequence, the component can be a pure function, therefore, is easier to test.

@taion
Copy link
Contributor

taion commented May 29, 2016

Take a look at async-props and react-router-relay for the recommended pattern for fetching data.

We're not duplicating these properties onto location, nor are we going to mutate the location object supplied by history – doing so is an anti-pattern.

@taion taion closed this May 29, 2016
@FredericHeem
Copy link
Author

FredericHeem commented May 29, 2016

Unfortunately, these 2 packages don't suit my requirements because fetching the data is coupled with the component lifecycle in these 2 cases.
How can we access the routes and the params inside a redux middleware ? This would be very useful.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants