Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!