UNPKG

cra-template-ipt-sun-context-crcf

Version:

The base template for Create React App with useContext folder structure dedicated for the creator of this template.

14 lines (10 loc) 333 B
import React, { useState, createContext } from "react"; export const CounterContext = createContext(); export const CounterProvider = (props) => { const [count, setCount] = useState(0); return ( <CounterContext.Provider value={[count, setCount]}> {props.children} </CounterContext.Provider> ); };