Async Results
Loading "Async Results"
Run locally for transcripts
π¨βπΌ Now that we have a web worker we can work with, let's refactor our
App
to
use this new async data source. We'll be using React's use
hook and passing
a promise to that. This means we'll want to have state for the promises of data
and an initial promise for when the app starts up (for the initial cities).
Also, we'll need a Suspense
boundary and we'll want to manage the pending
state with useTransition
.You'll know we made things better when you start a peformance profile and type
a single character in the search input. Compare the before/after flame graph and
you should notice a significant difference.
Tip: The easiest way to do this comparison is to run app in the
Problem
tab
and compare that one to the one in your Playground
tab in the workshop app.Good luck!