use-combined-reducers icon indicating copy to clipboard operation
use-combined-reducers copied to clipboard

Typescript: what is the correct way of providing types for the actions?

Open DirkWolthuis opened this issue 4 years ago • 1 comments

Hi!

 const [state, dispatch] = useCombinedReducers<
    { documentWizard: DocumentWizardState; steps: StepState },
    documentWizardActions & StepActions
  >({
    documentWizard: useReducer(
      documentWizardReducer,
      initialDocumentWizardState
    ),
    steps: useReducer(stepReducer, initialStepState),
  });

What is the correct way of providing the documentWizardActions & StepActions as second argument to the types of useCombinedReducers? The union operator does not work, also not the if ( | ) operator.

DirkWolthuis avatar Nov 03 '20 13:11 DirkWolthuis

I would like to see a typescript example for how to use combined reducer. I am getting som pretty strange type errors.

fmrogers avatar Feb 15 '22 21:02 fmrogers