mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-08 21:07:46 +00:00
Update CRA template for v5. (#7312)
This commit is contained in:
@@ -1,56 +1,24 @@
|
||||
import React from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import logo from './logo.svg';
|
||||
import './App.css';
|
||||
|
||||
function App() {
|
||||
const [date, setDate] = useState(null);
|
||||
useEffect(() => {
|
||||
async function getDate() {
|
||||
const res = await fetch('/api/date');
|
||||
const newDate = await res.text();
|
||||
setDate(newDate);
|
||||
}
|
||||
getDate();
|
||||
}, []);
|
||||
return (
|
||||
<main>
|
||||
<h1>Create React App + Go API</h1>
|
||||
<h2>
|
||||
Deployed with{' '}
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<p>
|
||||
Edit <code>src/App.js</code> and save to reload.
|
||||
</p>
|
||||
<a
|
||||
href="https://vercel.com/docs"
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Vercel
|
||||
Learn React
|
||||
</a>
|
||||
!
|
||||
</h2>
|
||||
<p>
|
||||
<a
|
||||
href="https://github.com/vercel/vercel/tree/main/examples/create-react-app"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
This project
|
||||
</a>{' '}
|
||||
was bootstrapped with{' '}
|
||||
<a href="https://facebook.github.io/create-react-app/">
|
||||
Create React App
|
||||
</a>{' '}
|
||||
and contains three directories, <code>/public</code> for static assets,{' '}
|
||||
<code>/src</code> for components and content, and <code>/api</code>{' '}
|
||||
which contains a serverless <a href="https://golang.org/">Go</a>{' '}
|
||||
function. See{' '}
|
||||
<a href="/api/date">
|
||||
<code>api/date</code> for the Date API with Go
|
||||
</a>
|
||||
.
|
||||
</p>
|
||||
<br />
|
||||
<h2>The date according to Go is:</h2>
|
||||
<p>{date ? date : 'Loading date...'}</p>
|
||||
</main>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user