From 3e7f5cbd876b29c92fc1cda58aa54a9c591ef026 Mon Sep 17 00:00:00 2001 From: rohan09-raj Date: Wed, 17 Aug 2022 16:37:42 +0530 Subject: lol --- client/src/context/User.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 client/src/context/User.js (limited to 'client/src/context/User.js') diff --git a/client/src/context/User.js b/client/src/context/User.js new file mode 100644 index 0000000..fce7eda --- /dev/null +++ b/client/src/context/User.js @@ -0,0 +1,28 @@ +import React, { createContext, useState, useContext } from 'react' + +export const UserContext = createContext() + +export const Context = ({ children }) => { + const [aadhaarNumber, setAadhaarNumber] = useState(null) + const [userData, setUserData] = useState({}) + + const initialUser = { + aadhaarNumber, + setAadhaarNumber, + userData, + setUserData + } + + return ( + {children} + ) +} + +export const userContext = () => { + const context = useContext(UserContext) + if (!context) { + throw new Error(`userContext context can only + be used in a component wrapped with UserContext`) + } + return context +} -- cgit