fix: fix context API issue
-wrap the entire app with context provider component -pass the context with the provider value
This commit is contained in:
parent
c947e488cc
commit
b9394e0e4d
|
@ -17,8 +17,8 @@ export const AuthContextProvider = ({ children }) => {
|
|||
}, [state.currentUser]);
|
||||
|
||||
return (
|
||||
<AuthContextProvider value={{ currentUser: state.currentUser, dispatch }}>
|
||||
<AuthContext.Provider value={{ currentUser: state.currentUser, dispatch }}>
|
||||
{children}
|
||||
</AuthContextProvider>
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -4,13 +4,16 @@ import "./index.css";
|
|||
import App from "./App";
|
||||
import reportWebVitals from "./reportWebVitals";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import { AuthContextProvider } from "./context/AuthContext";
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById("root"));
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
<AuthContextProvider>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</AuthContextProvider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue