Passing Functions or Strings
Explore how to decide between passing action creator functions or action type strings as parameters in Redux API middleware. Understand the trade-offs of each approach, including action serializability and debugging ease, to better manage async side effects in your Redux workflow.
We'll cover the following...
We'll cover the following...
A common dilemma when using the API middleware approach is deciding whether the onSuccess parameter should be an action creator:
import { setUserData } from '../actions/users';
const fetchUser = id => ({
type: API,
...