ReactJS – Effective load in React and React Native

When Redux is used to merge application state into React& React Native, why does the action creator need a type but no payload?

If the action has no payload attached, what is the purpose of the action creator?

Sometimes you have a reducer that does not return a new state based on the payload. An example is switching state The action of something in. The reducer only needs to know the trigger action to switch the attribute.
Example:

const lightSwitch = (
state = {on: false},
action,
) => {
switch (action.type) {
case TOGGLE:
return {...state, on: !state.on };
default: return state;
}
}

When Redux is used to use application state Incorporating into React & React Native, why does the action creator need a type but no payload?

If the action has no payload attached, what is the purpose of the action creator?

Sometimes you have a reducer that does not return to a new state based on the payload. An example is the action of switching something in the state. The reducer only needs Know the trigger action to switch attributes.
Example:

const lightSwitch = (
state = {on: false},
action ,
) => {
switch (action.type) {
case TOGGLE:
return {...state, on: !state.on };
default: return state;
}
}

Leave a Comment

Your email address will not be published.