Skip to content

Instantly share code, notes, and snippets.

@ChristianOConnor
Created March 22, 2023 23:17
Show Gist options
  • Save ChristianOConnor/c22e36dda9ee79a7728ee531002728ce to your computer and use it in GitHub Desktop.
Save ChristianOConnor/c22e36dda9ee79a7728ee531002728ce to your computer and use it in GitHub Desktop.
address collector frontend context/EmailContextManagement.tsx
import { createContext, useState } from 'react'
export const EmailContext = createContext({
email: "none",
setEmail: () => {}
})
export const EmailContextProvider = (props: any) => {
const setEmail = (email: string) => {
setState({...state, email: email})
}
const initState = {
language: "en",
setEmail: setEmail
}
const [state, setState] = useState(initState)
return (
<EmailContext.Provider value={state}>
{props.children}
</EmailContext.Provider>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment