How to Dispatch

How to dispatch snippet

Example below

Below example will clear the state of orgMembers.invitations (array)

dispatch({
  type: "orgMembers/setStates",
  payload: [],
  key: "invitations",
});

Below example will clear the state of tasks.partyTaskDetails (object)

dispatch({
  type: "tasks/setStates",
  payload: {},
  key: "partyTaskDetails",
});

Setting nested state

Below code will set leadDetails.followers to the value of the response.

  const leadDetails= yield select (({lead})=>lead.leadDeatails);
 
  yield put({
    type: 'setStates',
    payload: {...leadDetails, followers:response},
    key: 'leadDetails',
  });

Prefer using global state

See example below where lead owner details are being set and managed via state

dispatch({
  type: "lead/setStates",
  payload: { ...leadDetails, owner: selectedPersonRecord },
  key: "leadDetails",
});