feat: signout
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import SignOut from "../SignOut";
|
||||||
|
|
||||||
const Navbar = () => (
|
const Navbar = () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -16,6 +17,9 @@ const Navbar = () => (
|
|||||||
<li>
|
<li>
|
||||||
<Link to={"/register"}>Register</Link>
|
<Link to={"/register"}>Register</Link>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<SignOut />
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
11
src/components/SignOut/SignOut.js
Normal file
11
src/components/SignOut/SignOut.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import { withFirebase } from "../firebase";
|
||||||
|
|
||||||
|
const SignOutButton = ({ firebase }) => (
|
||||||
|
<button type="button" onClick={firebase.doSignOut}>
|
||||||
|
Sign Out
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default withFirebase(SignOutButton);
|
||||||
2
src/components/SignOut/index.js
Normal file
2
src/components/SignOut/index.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import SignOut from "./SignOut";
|
||||||
|
export default SignOut;
|
||||||
@@ -2,4 +2,10 @@ import React from "react";
|
|||||||
|
|
||||||
const FirebaseContext = React.createContext(null);
|
const FirebaseContext = React.createContext(null);
|
||||||
|
|
||||||
|
export const withFirebase = Component => props => (
|
||||||
|
<FirebaseContext.Consumer>
|
||||||
|
{firebase => <Component {...props} firebase={firebase} />}
|
||||||
|
</FirebaseContext.Consumer>
|
||||||
|
);
|
||||||
|
|
||||||
export default FirebaseContext;
|
export default FirebaseContext;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import FirebaseContext from "./context";
|
import FirebaseContext, { withFirebase } from "./context";
|
||||||
import Firebase from "./fire";
|
import Firebase from "./fire";
|
||||||
|
|
||||||
export default Firebase;
|
export default Firebase;
|
||||||
|
|
||||||
export { FirebaseContext };
|
export { FirebaseContext, withFirebase };
|
||||||
|
|||||||
Reference in New Issue
Block a user