//https://www.webune.com/forums/add-simple-react-ionic-context-provider-example-files-in-application.html import { createContext, useContext, useState } from "react"; const StateContext = createContext({ // allow variables to be updated useing state // use this to set the values for a given variable: example: notification currentUser: null, token: null, notification: null, setUser: () => { }, setToken: () => { }, setNotification: () => { }, }) export const ContextProvider = ({ children }:any) => { const [user, setUser] = useState({}); const [token, _setToken] = useState(localStorage.getItem('ACCESS_TOKEN')); const [notification, _setNotification] = useState(''); const setToken = (token:any) => { _setToken(token) if (token) { localStorage.setItem('ACCESS_TOKEN', token); } else { localStorage.removeItem('ACCESS_TOKEN'); } } const setNotification:any = (message:any) => { _setNotification(message); setTimeout(() => { _setNotification('') }, 5000) } // DEFINE ANY CONTS YOU WOUD LIKE TO SHARE TO ALL COMPONENTS - THESE WILL NEED TO BE ADDED TO THE RETURN BELOW // EXAMPLE: /* const tasks = [ 'I Followed instructions the first time.', 'I stayed on task.', 'I kept a calm body.', 'I tried not to distract my peers.', ]; */ // const emojis = ['😀', '😐', '☚ī¸', 'future', 'future', 'future', 'future', 'future', '❌', '
😀
']; // 10 limit 0-9 const emojis:string = "hell othere"; return ( {children} ); } export const useStateContext = () => useContext(StateContext);