import React from 'react'; import { useHistory } from 'react-router'; import { Link } from 'react-router-dom'; import { AUTH_TOKEN } from '../constants'; const Header = () => { const history = useHistory(); const authToken = localStorage.getItem(AUTH_TOKEN); return (
Hacker News
new
|
top
|
search {authToken && (
|
submit
)}
{authToken ? (
{ localStorage.removeItem(AUTH_TOKEN); history.push(`/`); }} > logout
) : ( login )}
); }; export default Header; // import React from 'react'; // import { useHistory } from 'react-router'; // import { Link, withRouter } from 'react-router-dom'; // const Header = () => { // const history = useHistory(); // return ( //
//
//
Hacker News
// // new // //
|
// // submit // //
//
// ); // }; // export default Header;