How to use the easy-peasy.useStoreDispatch function in easy-peasy

To help you get started, we’ve selected a few easy-peasy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ctrlplusb / easy-peasy / src / __tests__ / typescript / hooks.ts View on Github external
stateNumber: number;
  stateRegExp: RegExp;
  stateString: string;
  stateUndefined: undefined;
  stateUnion: string | null;
  actionImp: Action;
  actionNoPayload: Action;
  thunkImp: Thunk;
  reducerImp: Reducer;
  nested: {
    actionImp: Action;
    thunkImp: Thunk;
  };
}

let dispatch = useStoreDispatch();
dispatch({ type: 'FOO' });

let useStoreResult = useStoreState((state: State) => state.stateNumber);
useStoreResult + 1;
let useActionResult = useStoreActions(
  (actions: Actions) => actions.actionImp,
);
useActionResult(1);

let store = useStore();
store.getState().stateString + 'world';

const typedHooks = createTypedHooks();

useStoreResult = typedHooks.useStoreState(state => state.stateNumber);
useStoreResult + 1;