DEV Community

Discussion on: Fetching API data with ReactJS

Collapse
 
sveg_pl profile image
Wojtek Babicz

The lifecycle method componentWillMount has been deprecated since react version 16.3 (around March '18), so I wouldn't recommend using it. It's been replaced with UNSAFE_componentWillMount obviously meant for the legacy codebase upkeep. Feel free to implement data fetching in the componentDidMount function or even outside of the view component when external state management (e.g., redux) is used in your stack.