katoikia-app/mobile-ui/context/UserContext.js

24 lines
492 B
JavaScript
Raw Permalink Normal View History

2022-08-22 20:22:27 +00:00
import React, { createContext, useState } from 'react'
export const UserContext = createContext({});
export const UserContextProvider = ({ children }) => {
const [user, setUser] = useState(null);
const addUser = (user) => setUser(user);
const removeUser = () => setUser(null);
const value = {
user,
addUser,
removeUser
}
return (
<UserContext.Provider value={value}>
{children}
</UserContext.Provider>
)
}