Open
Code
Home
Create
List
Home
Create
List
Edit
Title
Content
To use the useContext you need to set 3 points, the Context setup, the provider file and the receiver file. UserContext.js import { createContext } from "react"; export const MyContext = createContext(null); App.js import { MyContext } from "./UserContext.js" App()... const [value, setValue] = useState("string"); return... <MyContext.Provider value={{ value, setValue }}> ... </MyContext.Provider> MovieCard.js import { MyContext } from "./UserContext.js" MovieCard... const { value, setValue } = useContext(MyContext);
Image
Category
Categories
Front-End
Back-End
Database
DevOps
Others
Password
Back to List