https://github.com/ericclemmons/react.lazy-example
Testing out React.lazy (https://github.com/facebook/react/pull/13398)
https://github.com/ericclemmons/react.lazy-example
Last synced: over 1 year ago
JSON representation
Testing out React.lazy (https://github.com/facebook/react/pull/13398)
- Host: GitHub
- URL: https://github.com/ericclemmons/react.lazy-example
- Owner: ericclemmons
- Created: 2018-08-28T05:23:50.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-04T06:05:38.000Z (almost 8 years ago)
- Last Synced: 2025-03-10T19:03:21.134Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://react-lazy-example-qmehmnudqu.now.sh/
- Size: 45.9 KB
- Stars: 24
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
import Demo from "./src/components/Demo"
import Layout from "./src/components/Layout"
export default Layout
---
# `React.lazy` Example
After [@acdlite](https://github.com/acdlite) merged https://github.com/facebook/react/pull/13398,
I was curiuos if it would be possible to render an **async component** like:
```jsx
async function Repos({ user }) {
const res = await fetch(...)
const repos = await res.json()
return
- {repos.map(...)}
}
```
## Demo
_Available at https://react-lazy-example-qmehmnudqu.now.sh/_
>
---
## Local Development
1. Clone this repo.
1. Next, we need a custom build of React with Suspense enabled:
1. `git submodule update` to install https://github.com/facebook/react/.
1. `yarn patch` to set `enableSuspense = true`
1. `yarn build` to build React with Suspense.
1. `yarn install`
1. `yarn dev`