MCPcopy Create free account
hub / github.com/epicweb-dev/react-suspense / App

Function App

exercises/04.image/02.problem.error/index.tsx:7–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import { getImageUrlForShip, getShip, imgSrc } from './utils.tsx'
6
7function App() {
8 const [shipName, setShipName] = useState('Dreadnought')
9 const [isTransitionPending, startTransition] = useTransition()
10 const isPending = useSpinDelay(isTransitionPending, {
11 delay: 300,
12 minDuration: 350,
13 })
14
15 function handleShipSelection(newShipName: string) {
16 startTransition(() => {
17 setShipName(newShipName)
18 })
19 }
20
21 return (
22 <div className="app-wrapper">
23 <ShipButtons shipName={shipName} onShipSelect={handleShipSelection} />
24 <div className="app">
25 <div className="details" style={{ opacity: isPending ? 0.6 : 1 }}>
26 <ErrorBoundary fallback={<ShipError shipName={shipName} />}>
27 <Suspense fallback={<ShipFallback shipName={shipName} />}>
28 <ShipDetails shipName={shipName} />
29 </Suspense>
30 </ErrorBoundary>
31 </div>
32 </div>
33 </div>
34 )
35}
36
37function ShipButtons({
38 shipName,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected