Skip to content

Commit

Permalink
#11 Add current user provider
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jun 21, 2023
1 parent 0e67628 commit 94e42f0
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Route, Switch } from "react-router-dom";
import "./api/axiosDefaults";
import SignUpForm from "./pages/auth/SignUpForm";
import LoginForm from "./pages/auth/LoginForm";
import { createContext, useState } from "react";
import { createContext, useEffect, useState } from "react";
import axios from "axios";

export const CurrentUserContext = createContext();
Expand All @@ -22,18 +22,26 @@ function App() {
}
};

useEffect(() => {
handleMount();
}, []);

return (
<div className={styles.App}>
<NavBar />
<Container className={styles.Main}>
<Switch>
<Route exact path="/" render={() => <h1>Home Page</h1>} />
<Route exact path="/login" render={() => <LoginForm />} />
<Route exact path="/signup" render={() => <SignUpForm />} />
<Route render={() => <p>Page not found!</p>} />
</Switch>
</Container>
</div>
<CurrentUserContext.Provider value={currentUser}>
<SetCurrentUserContext.Provider value={setCurrentUser}>
<div className={styles.App}>
<NavBar />
<Container className={styles.Main}>
<Switch>
<Route exact path="/" render={() => <h1>Home Page</h1>} />
<Route exact path="/login" render={() => <LoginForm />} />
<Route exact path="/signup" render={() => <SignUpForm />} />
<Route render={() => <p>Page not found!</p>} />
</Switch>
</Container>
</div>
</SetCurrentUserContext.Provider>
</CurrentUserContext.Provider>
);
}

Expand Down

0 comments on commit 94e42f0

Please sign in to comment.