Problem Statement
Explain the purpose of Redux Thunk in React Native.
Explanation
Redux Thunk is a middleware that allows you to write action creators that return a function instead of an action object.
This function can perform asynchronous tasks such as fetching data before dispatching the actual action, making it ideal for network calls in React Native apps.
Code Solution
SolutionRead Only
export const fetchUsers = () => async dispatch => { const res = await api.get('/users'); dispatch({ type: 'SET_USERS', payload: res.data }); };