export default function App()

in databases/hello-app-cloud-spanner/client/src/components/App.js [27:60]


export default function App() {
    const [error, setError] = useState('');
    const [players, setPlayers] = useState([]);

    useEffect(() => {
        const fetchPlayers = async () => {
            try {
                const response = await getPlayers();
                setPlayers(response.data);
                setError('');
            } catch(error) {
                setError('Error fetching players from database');
            }
        };
        fetchPlayers();
    }, []);

    return <LocalizationProvider dateAdapter={AdapterDayjs}>
        <Container maxWidth="md">
            <CssBaseline />
            <Grid container rowSpacing={2}>
                <Grid container direction="row" justifyContent="center" item xs={12}>
                    <Typography variant="h3">Players Registry</Typography>
                </Grid>
                <Grid item xs={12}>
                    <Divider />
                </Grid>
                {error !== '' &&
                    <Grid container style={{ marginBottom: "15px" }}>
                        <Grid item xs={12}>
                            <Alert severity="error" onClose={() => setError('')}>{error}</Alert>
                        </Grid>
                    </Grid>
                }