componentesreactjs
v1.0.0
Published
List of Components and hooks Reactjs to many utilities...
Downloads
3
Readme
==>Colar envolto da aplicação principal:
ContextApp.jsx: import { createContext } from 'react'; const TokenContext = createContext(null) export default TokenContext;
Provider.js: import ContextApp from './ContextApp'; const Store_token = ({children})=>{ const [token,setToken] = useState(sessionStorage.token); const [redirect,setRedirect] = useState(""); const [idCurrentEntity,setIdCurrentEntity] = useState(sessionStorage.idBranch); let [dialog, setDialog] = useState({ open: false, index: null, type: "alert", title: "", message: "", cb: ()=>{ }, cb2:()=>{} }); let [loading, setLoading] = useState({ open: false });
return(
<ContextApp.Provider value={{
token,setToken,
redirect,setRedirect,
idCurrentEntity,setIdCurrentEntity,
dialog, setDialog,
loading, setLoading,
}}>
{children}
<Dialog open={dialog.open} toggleShow={e=>setDialog({open:false})} {...dialog} />
<Loading open={loading.open} />
</ContextApp.Provider>
)
}