doc: add StateProvider and StateValue
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import React, { createContext, useContext, useReducer } from "react";
|
||||
|
||||
export const StateContext = createContext();
|
||||
|
||||
export const StateProvider = ({ reducer, initialState, children }) => (
|
||||
<StateContext.Provider value={useReducer(reducer, initialState)}>
|
||||
{children}
|
||||
</StateContext.Provider>
|
||||
);
|
||||
|
||||
export const useStateValue = () => useContext(StateContext);
|
||||
|
||||
Reference in New Issue
Block a user