An open API service indexing awesome lists of open source software.

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)

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`