| 1. |
What do you understand about Redux Thunk? |
|
Answer» USING Redux Thunk middleware, we can write action creators returning a function instead of an action. This thunk can postpone the dispatch of an action, or do conditional dispatchment. The arguments passed to the inner function are the store methods dispatch and getState(). In the event of an action creator returning a function, the function gets executed by the Redux Thunk middleware and it does not have to be pure. In other words, the function is allowed to have side EFFECTS, including executing asynchronous API CALLS. It can even dispatch actions. Redux thunk is used to delay the dispatch of an action, or to dispatch in the event of a CERTAIN condition being met. At the time of dispatch of a function instead of an action object, if Redux Thunk middleware is enabled, the middleware will call that function with the dispatch method itself as the first argument. |
|