use-context-hook
Version:
React use-context-hook use-context-hook
25 lines (21 loc) • 531 B
JSX
/* eslint-disable react-hooks/rules-of-hooks */
import React, { useState } from "react";
import { createContextHook } from "use-context-hook";
const context = {};
export const Context = createContextHook(context);
export function ContextProvider(props) {
const [count, setCount] = useState(0);
const [text, setText] = useState("hello world");
return (
<Context.Provider
value={{
count,
setCount,
text,
setText,
}}
>
{props.children}
</Context.Provider>
);
}