Skip to content

Instantly share code, notes, and snippets.

@r3dm1ke
Created May 27, 2020 16:16
Show Gist options
  • Save r3dm1ke/60c6ab607c4ab4d5da505039a02786a3 to your computer and use it in GitHub Desktop.
Save r3dm1ke/60c6ab607c4ab4d5da505039a02786a3 to your computer and use it in GitHub Desktop.
import React, {Suspense} from 'react';
const cars = loadCarsFromServer(); // Start loading early
const App = () => (
<Suspense fallback={<h1>Loading cars</h1>}>
<CarDetails />
</Suspense>
);
const CarDetails = () => {
const car = cars.read(); // Syncronous, blocking call
return (<h1>{car.name}</h1>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment