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

265
Visualizações
blank screen after wrapping App component with react-context

I am writing the context API and everything is working fine but when I wrapped the App component with the context screen became blank

Code of contex

import { useState } from "react";
import { createContext, useContext } from "react";

const chatContext = createContext();

const ChatContext = ({ childern }) => {
  const [user, setuser] = useState();
  return (
    <chatContext.Provider value={{ user, setuser }}>
      {childern}
    </chatContext.Provider>
  );
};

export const ChatState = () => {
  return useContext(chatContext);
};

export default ChatContext;

code of index.js before wrapping contex

ReactDOM.render(
  <React.StrictMode>
    <Router>
      <App />
    </Router>
  </React.StrictMode>,
  document.getElementById("root")
);

**code after wrapping context api **

import ChatContext from "./Context/ChatContext";

ReactDOM.render(
  <ChatContext>
    <Router>
      <App />
    </Router>
  </ChatContext>,
  document.getElementById("root")
);

but the screen becomes blank anyone how can help me.

I tried to solve this problem but can not able to do so. plz anyone how can help me will be appricated

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

i think you just misspelled children you wrote childern and if you fix how you wrote it the problem will be solved

const ChatContext = ({ *childern* children }) => {
  const [user, setuser] = useState();
  return (
    <chatContext.Provider value={{ user, setuser }}>
      {*childern* children}
    </chatContext.Provider>
  );
};

export const ChatState = () => {
  return useContext(chatContext);
};

export default ChatContext;

about 4 years ago · Juan Pablo Isaza Relatório
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