Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

228
Visualizações
Redux hooks don't work inside the Next JS Head Tag

I was setting up redux in my Next JS project but the useDispatch hook wasn't working inside my Nav component. The nav was wrapped in the tag provided by Next JS. But when I moved my Nav component outside the tag, the useDispatch hook started working. Why is my app behaving like this?

Error: react-redux context value error

_app.js:

import "../styles/globals.css"; 
import { useStore } from "../app/store/store";
import { Provider } from "react-redux"; 2
export default function App({ Component, pageProps }) {
    const store = useStore(pageProps.initialReduxState); 
    return (
        <Provider store="{store}">
            <Component {...pageProps} />
        </Provider>
    )
}

index.js:

import styles from "../styles/Home.module.css";
import Head from "next/head";
import { useEffect } from "react";
import { useDispatch } from "react-redux";
import { authCheckState } from "../app/store/actions/auth";

import Nav from "../app/components/Nav";
import Footer from "../app/components/Footer";
import MainCarousel from "../app/components/MainCarousel";
import BestSellers from "../app/components/BestSellers";

export default function Home() {
  const dispatch = useDispatch();
  useEffect(() => {
    dispatch(authCheckState());
  });
  return (
    <>
      <Head>
        <Nav />
      </Head>
      <main className={styles.main}>
        <MainCarousel />
        <BestSellers />
      </main>
      <Footer />
    </>
  );
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda