I am new to redux with react.I don't know why below code contains 2 arrow function and the purpose of it.
export const loadName = () => (dispatch: any) => {
const name = localStorage.getItem('name');
dispatch(setName(name));
}
I am new to redux with react.I don't know why below code contains 2 arrow function and the purpose of it.
export const loadName = () => (dispatch: any) => {
const name = localStorage.getItem('name');
dispatch(setName(name));
}
Basically it's a function returning another function, equivalent to:
export const loadName = () => {
return (dispatch: any) => {
const name = localStorage.getItem('name');
dispatch(setName(name));
};
};
this I think -- it's just shorter to use an arrow instead of writing function, and allows you to write it in one line