Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

1import React, { useState, useEffect } from 'react'; 2import { Provider } from 'urql'; 3 4import client from './client'; 5import Links from './pages/Links'; 6import LoginForm from './pages/LoginForm'; 7 8const Home = () => { 9 const [isLoggedIn, setIsLoggedIn] = useState(false); 10 11 const onLoginSuccess = auth => { 12 localStorage.setItem('authToken', auth.token); 13 setIsLoggedIn(true); 14 }; 15 16 useEffect(() => { 17 if (localStorage.getItem('authToken')) { 18 setIsLoggedIn(true); 19 } 20 }, []); 21 22 return isLoggedIn ? <Links /> : <LoginForm onLoginSuccess={onLoginSuccess} />; 23}; 24 25function App() { 26 return ( 27 <Provider value={client}> 28 <Home /> 29 </Provider> 30 ); 31} 32 33export default App;