How to use redux-react-hook - 10 common examples

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 jauhararifin / ugrade / desktop / src / contest / problem / useProblemList.ts View on Github external
export function useProblemList() {
  useProblems()
  return useMappedState(getProblemList)
}
github jauhararifin / ugrade / desktop / src / contest / submission / useSubmissionList.ts View on Github external
export function useSubmissionList() {
  useSubmissions()
  return useMappedState(getSubmissionList)
}
github jauhararifin / ugrade / web / src / contest / announcement / useAnnouncements.ts View on Github external
export function useAnnouncements() {
  const dispatch = useAppThunkDispatch()

  useSingleEffect(
    'USE_ANNOUNCEMENTS',
    () => {
      const subs = dispatch(subscribeAnnouncementsAction())
      return () => {
        subs.then(unsub => unsub()).catch(globalErrorCatcher)
      }
    },
    []
  )

  return useMappedState((state: AppState) => state.contest.announcements)
}
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: {
github mmazzarolo / just-tap / src / containers / Menu.tsx View on Github external
export const Menu: FunctionComponent = memo(() => {
  console.warn(" - ");
  const { highScore } = useMappedState(mapState);
  const { navigateToPlayground } = useMappedActions(mapActions);
  const [animationStatus, setAnimationStatus] = useState<"showing" | "hiding">(
    "showing"
  );

  const handlePress = async () => {
    setAnimationStatus("hiding");
    await delay(MENU_ANIM_DURATION);
    navigateToPlayground();
  };

  return (
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 / pages / __Dashboard / Dashboard.js View on Github external
const Dashboard = props => {
  const { classes } = props;

  const {
    packages,
    packagesOutdated,
    loading,
    directory,
    mode,
    projectName,
    projectVersion,
    projectDescription,
    projectLicense,
    lastUpdatedAt
  } = useMappedState(mapState);

  const title =
    mode === APP_MODES.LOCAL ? `Project ${projectName || ''}` : 'Global';
  const text =
    mode === APP_MODES.LOCAL ? projectDescription : APP_INFO.GLOBAL_MESSAGE;

  return (
    <section>
      
        
          </section>
github jauhararifin / ugrade / desktop / src / scenes / Dashboard / TopNavigationBar / TopNavigationBar.tsx View on Github external
export const TopNavigationBar: FunctionComponent = () => {
  useContestOnly()
  const user = useMe()
  const breadcrumbs = useMappedState(selectBreadcrumb)
  const push = usePush()
  const signOut = useSignOut()

  const breadcrumbWithRouter = breadcrumbs.map(breadcrumbItem => ({
    ...breadcrumbItem,
    onClick: () => {
      if (breadcrumbItem.href) push(breadcrumbItem.href)
    },
    href: undefined,
  }))

  const handleSignOut = async () => {
    await signOut()
    TopToaster.showSuccessToast('Signed Out')
  }
  const handleMyAccount = () => push('/account')

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