mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 18:26:34 +02:00
12 lines
345 B
TypeScript
12 lines
345 B
TypeScript
import React from "react";
|
|
|
|
export const UserNameContext =
|
|
React.createContext<[string, (userName: string) => void] | null>(null);
|
|
|
|
export const useUserName = () => {
|
|
const contextValue = React.useContext(UserNameContext);
|
|
if (contextValue === null) {
|
|
throw new Error("Missing UserNameContext.Provider");
|
|
}
|
|
return contextValue;
|
|
};
|