1 RN Thing a Day – Day 13: Redux Thunk
Ola Abaza
What Is Redux Thunk? Redux Thunk is a middleware for Redux that allows you to write action creators that return a function instead of a plain action object. Normally, Redux actions look like this: { type : " SET_USER " , payload : user } async code doesn't work directly: Redux would throw an error because it expects an object. dispatch ( async () => { const data = await api . getUser () }) But with thunk, you can return a function: const fetchUser = () => { // Return an async function that recei
