export const increment = () => ({
type: INCREMENT
});
why is ({}) after => instead of {}? can you give me an explanation or say what's this so I can do my research on this? Thank you.
export const increment = () => ({
type: INCREMENT
});
why is ({}) after => instead of {}? can you give me an explanation or say what's this so I can do my research on this? Thank you.
If you want to return an object from a traditional function this would be
function increment() {
return {type: INCREMENT};
}
And this works:
export const increment = () => {
return {
type: INCREMENT
}
};
But this wouldnt
export const increment = () =>
{
type: INCREMENT
};
If you want to return an object from an arrow function you can wrap it in ()