Skip to content
On this page

useContext

类似于vue 中的Provider

jsx
const ThemeContext = createContext(null);

    <ThemeContext.Provider value="dark">
      <Form />
    </ThemeContext.Provider>

    const theme = useContext(ThemeContext);