Skip to content

Instantly share code, notes, and snippets.

@kenny-io
Last active April 7, 2024 20:08
Show Gist options
  • Select an option

  • Save kenny-io/f0b0845f8e5f3a2d6bea024d7f3e9310 to your computer and use it in GitHub Desktop.

Select an option

Save kenny-io/f0b0845f8e5f3a2d6bea024d7f3e9310 to your computer and use it in GitHub Desktop.

Revisions

  1. kenny-io revised this gist Apr 7, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion codesplit.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    import React, { lazy, Suspense } from 'react';
    import { lazy, Suspense } from 'react';

    const ProductDetails = lazy(() => import('./ProductDetails'));

  2. kenny-io created this gist Apr 7, 2024.
    17 changes: 17 additions & 0 deletions codesplit.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    import React, { lazy, Suspense } from 'react';

    const ProductDetails = lazy(() => import('./ProductDetails'));

    function ProductListing({ products }) {
    return (
    <Suspense fallback={<div>Loading...</div>}>
    <ul>
    {products.map((product) => (
    <li key={product.id}>
    <ProductDetails product={product} />
    </li>
    ))}
    </ul>
    </Suspense>
    );
    }