I'm currently working through a tutorial on React and I'm having trouble understanding the syntax of these arrow functions, particularly when there are multiple parameters. I'm coming from Python and am still learning JS so please keep that in mind.
With the following function:
// ADD LEAD
export const addLead = (lead) => (dispatch, getState) => {
axios
.post('/api/leads/', lead, tokenConfig(getState))
.then(........)
}
Why do we need multiple arrows? Why is lead
in one set of parenthesis and dispatch
and getState
in another set? Coming from Python this syntax is incredibly confusing and non-intuitive.
Thanks for any help!