Add logout
This commit is contained in:
parent
695927b9e8
commit
13e2851e4c
|
@ -3,7 +3,7 @@ import PropTypes from "prop-types";
|
|||
|
||||
export default (player) => {
|
||||
function Login(props) {
|
||||
const [input, setInput] = useState(localStorage.getItem("token"));
|
||||
const [input, setInput] = useState(localStorage.getItem("token") ? localStorage.getItem("token"): "" );
|
||||
return (
|
||||
<div className="login">
|
||||
<input type="text" placeholder="Token ID" value={input}
|
||||
|
|
|
@ -1,7 +1,23 @@
|
|||
import React from "react";
|
||||
export default () => function MainApp() {
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
export default () => {
|
||||
function MainApp(props) {
|
||||
return (
|
||||
<div className="main">
|
||||
<header>
|
||||
<p>Questable</p>
|
||||
<button
|
||||
onClick={() => {
|
||||
props.setLoggedIn(false);
|
||||
localStorage.removeItem("token");
|
||||
}}>Logout</button>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
MainApp.propTypes = {
|
||||
setLoggedIn: PropTypes.func,
|
||||
};
|
||||
return MainApp;
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ const MainApp = mainapp();
|
|||
|
||||
function App(){
|
||||
const [loggedIn, setLoggedIn] = useState(false);
|
||||
return loggedIn ? <MainApp /> : <Login setLoggedIn={setLoggedIn} />;
|
||||
return loggedIn ? <MainApp setLoggedIn={setLoggedIn} /> : <Login setLoggedIn={setLoggedIn} />;
|
||||
}
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById("root"));
|
||||
|
|
Loading…
Reference in New Issue