A thunk function is a function created to handle async logic, like calling an API. It takes two arguments dispatch and getState to dispatch actions and have access to the current state if needed.
Redux Toolkit provides the createAsyncThunk API to generate thunks easily. fetchUserById is the thunk function created here.
Besides letting you create thunk functions for API calls, createAsyncThunk automatically dispatches actions to track the state of API requests.
The extraReducers field in our userSlice is used to handle state status changes.