forked from netlify/create-react-app-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
39 lines (35 loc) · 928 Bytes
/
App.js
File metadata and controls
39 lines (35 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, {
unstable_ConcurrentMode as ConcurrentMode,
unstable_Suspense as Suspense,
Component
} from 'react';
import logo from './logo.svg';
import './App.css';
import { createFetcher } from './cache';
const DataResource = createFetcher(() =>
fetch(`/.netlify/functions/hello`).then(x => x.json())
);
function LambdaDemo() {
const msg = DataResource.read().msg;
return <p>{msg}</p>;
}
class App extends Component {
render() {
return (
<ConcurrentMode>
<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>
<Suspense maxDuration={1000} fallback={'Loading...'}>
<LambdaDemo />
</Suspense>
</header>
</div>
</ConcurrentMode>
);
}
}
export default App;