A thunk is a function that wraps an expression to delay its evaluation.
Redux Thunk middleware allows you to write action creators that return a function instead of an action. The thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met. The inner function receives the store methods
getState as parameters.
One of the main use cases for this middleware is for handling actions that might not be synchronous, for example, using axios to send a
GET request. Redux Thunk allows us to dispatch those actions asynchronously and resolve each promise that gets returned.
#Redux #Middleware #Dispatch #Probyto #ProbytoAI
Subscribe & Follow us for latest in field of AI & Tech and stay updated!