Context Display Problem #4
-
import { createContext, useContext, useState } from "react"; const ChatContext = createContext(); export const ChatProvider = ({ children }) => { const values = { export const useChat = () => useContext(ChatContext); This is how I created the context but I can't use it on the page. Why can't the data I load into the context appear? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You should send the data you created with hello context to your page (ChatContext.Provider). I think the error comes from here. You can modify the code block below. return <ChatContext.Provider value={values}>{children}</ChatContext.Provider>; |
Beta Was this translation helpful? Give feedback.
You should send the data you created with hello context to your page (ChatContext.Provider). I think the error comes from here. You can modify the code block below.
return <ChatContext.Provider value={values}>{children}</ChatContext.Provider>;