Skip to content

ericclemmons/react.lazy-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


import Demo from "./src/components/Demo" import Layout from "./src/components/Layout"

export default Layout


React.lazy Example

After @acdlite merged facebook/react#13398, I was curiuos if it would be possible to render an async component like:

async function Repos({ user }) {
  const res = await fetch(...)
  const repos = await res.json()

  return <ul>{repos.map(...)}</ul>
}

Demo

Available at https://react-lazy-example-qmehmnudqu.now.sh/


Local Development

  1. Clone this repo.

  2. Next, we need a custom build of React with Suspense enabled:

    1. git submodule update to install https://github.com/facebook/react/.
    2. yarn patch to set enableSuspense = true
    3. yarn build to build React with Suspense.
  3. yarn install

  4. yarn dev