Echo JS 0.11.0

<~>

tracker1 1676 days ago. link 2 points
Been using the redux hooks for a project, and really been enjoying it.  My actions modules are exposing a default useActions that wraps useReducer, useMemo and bindActions which keeps the action bindings with the actions instead of each component, which has been really nice.

    import { useMemo } from 'react';
    import { bindActionCreators } from 'redux';
    import { useDispatch } from 'react-redux';
    ...
    const doSomething = (input) => ({ type: 'sometype', ... });
    ...
    ...
    export default deps => {
      const dispatch = useDispatch();
      return useMemo(
        () =>
          bindActionCreators(
            {
              doSomething,
              ...
            },
            dispatch
          ),
        deps ? [dispatch, ...deps] : [dispatch]
      );
    };