ericclemmons / react.lazy-example

Testing out React.lazy (https://github.com/facebook/react/pull/13398)

Home Page:https://react-lazy-example-qmehmnudqu.now.sh/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


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

About

Testing out React.lazy (https://github.com/facebook/react/pull/13398)

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


Languages

Language:JavaScript 88.8%Language:HTML 11.2%