UNPKG

react-tailwind-context

Version:

A starter template for a React + Vite + Tailwind project with Context API setup. This template is a good starting point for a new project.

21 lines (16 loc) 469 B
import React, { createContext, useContext, useState } from 'react'; const Context = createContext(); export const StateContext = ({ children }) => { const [count, setCount] = useState(0); return ( <Context.Provider value={{ count, setCount, }} > {children} </Context.Provider> ); }; export const useStateContext = () => useContext(Context);