[Solved] How to Redux a Reactjs crime map application


Here is the flow of the code you have shared
1. When the component mounts, it calls a function
2. this function “fetchPostsWithRedux” then dispatches actions also, it send an api call to server to fetch data
3. when the data is received component re-renders with updated data as prop.

Now if you want to use mapLayerData function to give the data to the component, without using the “old fetch method”, you can do it as mentioned below

add a function naming componentWillReceiveProps

componentWillReceiveProps(nextProps){

    this.setState({markers: this.mapLayerData(nextProps.posts)});

}

Once you call this, state of the component will now have the data, that we have received from the api call

Hope the above solution has given some clarity about it.

1

solved How to Redux a Reactjs crime map application