How to use the redux-react-hook.useDispatch function in redux-react-hook

To help you get started, we’ve selected a few redux-react-hook 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 react-love / react-latest-framework / src / components / BaseLayout / index.js View on Github external
export default function BaseLayout(props) {
    const store = useContext(StoreContext)
    const { isLogin } = store.getState().toJS().global
    const dispatch = useDispatch()

    const pathname = props.location.pathname
    // 初始化state
    const initalState = {
        currentMenu: formatSecondMenu(pathname),
        menuData: {
            theme: 'dark', // 菜单主题色
            defaultSelectedKeys: pathname, // 当前默认值
            mode: 'inline', // 菜单模式
            defaultOpenKeys: formatFirstMenu(pathname),
            list: userData
        }
    }
    const [state, setState] = useState(initalState)
    const { menuData, currentMenu } = state
    const { history } = props
github rvpanoz / luna / app / components / packages / Packages.js View on Github external
const Packages = props => {
  const { packages, mode, directory } = useMappedState(mapState);
  const dispatch = useDispatch();

  const [newPackages, error] = useIpc(
    'ipc-event',
    merge(options, {
      mode,
      directory
    })
  );

  if (error) {
    console.error(error);
  }

  useEffect(
    () => {
      if (typeof newPackages === 'string' && !Boolean(newPackages.length)) {
github rvpanoz / luna / app / containers / Audit.js View on Github external
const Audit = ({ classes }) => {
  const { loading, message, mode, result } = useMappedState(mapState);
  const [metadataValues, setMetadata] = useState({
    dependencies: 0,
    devDependencies: 0,
    optionalDependencies: 0,
    vulnerabilities: null,
    advisories: null
  });
  const dispatch = useDispatch();
  const { content, error } = result || {};

  const auditRun = option =>
    dispatch(
      runAudit({
        ipcEvent: 'npm-audit',
        cmd: ['audit'],
        options: {
          flag: option || false
        }
      })
    );

  const dialogText = mode === 'global' ? iMessage('warning', 'noGlobalAudit') : iMessage('info', 'npmAuditInfo');
  const dialogActionText = iMessage('action', 'runAudit');
github rvpanoz / luna / app / components / views / audit / FixOptions.js View on Github external
const AuditOptions = ({ classes, packagesInstallOptions, selected }) => {
  const dispatch = useDispatch();

  return (
    <div>
      
        {INFO_MESSAGES.fixOptions}
      
      
      
        
          package-lock only
            }
          /&gt;
          
        </div>
github rvpanoz / luna / app / containers / Packages.js View on Github external
packagesInstallOptions,
    active,
    operationStatus,
    operationPackages,
    operationCommand,
  } = useMappedState(mapState);

  const [options, toggleOptions] = useState({
    open: false,
    single: false,
    name: null,
    version: null
  });
  const [filteredByNamePackages, setFilteredByNamePackages] = useState([]);
  const wrapperRef = useRef(null);
  const dispatch = useDispatch();

  const reload = useCallback(() => {
    dispatch(setActivePage({ page: 'packages', paused: false }));
    dispatch(
      setPackagesStart({
        channel: 'npm-list-outdated',
        options: {
          cmd: ['outdated', 'list']
        }
      })
    );
  }, [dispatch]);

  const switchModeHandler = useCallback((appMode, appDirectory) => {
    dispatch(setMode({ mode: appMode, directory: appDirectory }));
    dispatch(setActivePage({ page: 'packages', paused: false }));
github jauhararifin / ugrade / desktop / src / common / useAppThunkDispatch.ts View on Github external
export function useAppThunkDispatch() {
  return useDispatch() as AppThunkDispatch
}
github rvpanoz / luna / app / containers / AppLayout.js View on Github external
const AppLayout = ({ classes }) =&gt; {
  const { activePage, snackbar } = useMappedState(mapState);
  const dispatch = useDispatch();

  const onClose = useCallback(() =&gt;
    dispatch(
      setSnackbar({
        ...snackbar,
        open: false,
        message: null,
        type: 'info',
        hideOnClose: false
      })
    ), [dispatch, snackbar]);

  const { hideOnClose } = snackbar;

  return (
github rvpanoz / luna / app / components / views / notifications / List.js View on Github external
const NotificationsList = ({ classes }) => {
  const { notifications } = useMappedState(mapState);
  const dispatch = useDispatch();

  const onSearchHandler = packageName => {
    dispatch(clearFilters());

    dispatch({
      type: setActivePage.type,
      payload: {
        page: 'packages',
        paused: true
      }
    });

    dispatch(
      setPackagesSearch({
        channel: 'npm-search',
        options: {
github quiltdata / quilt / catalog / app / containers / Auth / Provider.js View on Github external
const useNotificationHandlers = () => {
  const intl = useIntl()
  const dispatch = useDispatch()
  return React.useMemo(
    () => ({
      onAuthLost: () => {
        dispatch(notify(intl.formatMessage(msg.notificationAuthLost)))
      },
    }),
    [intl, dispatch],
  )
}
github rvpanoz / luna / app / containers / AppTopBar.js View on Github external
notifications,
    loading,
    activePage
  } = useMappedState(mapState);

  const [initFlow, toggleInitFlow] = useState({
    show: false,
    directory: null
  })
  const [dialog, setDialog] = useState({
    open: false,
    title: '',
    active: null
  });

  const dispatch = useDispatch();

  const onLoadDirectory = useCallback(() => {
    const dialogHandler = filePath => {
      dispatch(
        setActivePage({
          page: 'packages',
          paused: false
        })
      );
      dispatch(setMode({ mode: 'local', directory: filePath.join('') }));
    };

    return showDialog(dialogHandler, { mode: 'file', ...navigatorParameters });
  }, [dispatch]);

  const closeDialog = useCallback(() => {

redux-react-hook

React hook for accessing a Redux store.

MIT
Latest version published 4 years ago

Package Health Score

59 / 100
Full package analysis