React with Redux fetch should be in componentDidMount not componentWillMount #676

Closed
opened 2025-08-09 17:17:13 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @PaulKGray on 6/9/2017

Hi

I used the JavaScript template and came up with an issue when copying the pattern that having the fetch call in componentWillMount caused it to call the API multiple times when the logic to check if the parameter has changed has gone.

If the call to fetch is moved to componentDidMount this means it is only called once.

Although the weather page is ok its difficult to understand why this is happening when using the supplied redux store pattern.

*Originally created by @PaulKGray on 6/9/2017* Hi I used the JavaScript template and came up with an issue when copying the pattern that having the fetch call in componentWillMount caused it to call the API multiple times when the logic to check if the parameter has changed has gone. If the call to fetch is moved to componentDidMount this means it is only called once. Although the weather page is ok its difficult to understand why this is happening when using the supplied redux store pattern.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#676
No description provided.