I am very new to Redux so please bear with me now.
My friend suggested that instead of having my axios calls inside of my componentDidMount()
I should place them in an action file. Here's the snippet:
componentDidMount() {
axios.get('http://xxxx/customers').then(res => {
this.setState({
res,
customer: res.data
})
})
axios.get('http://xxxx/events').then(res => {
this.setState({
res,
event: res.data
})
})
axios.get('http://xxxx/locks').then(res => {
this.setState({
res,
lock: res.data
})
})
}
And I understand that to change the application's state I need to dispatch and action:
But the thing is that I am really uncertain how to set this all up. If anyone has some tips I'll be really happy to take them.