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

Function App

exercises/02.dynamic/01.problem.cache/index.tsx:6–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import { getImageUrlForShip, getShip } from './utils.tsx'
5
6function App() {
7 const [count, setCount] = useState(0)
8 const [shipName, setShipName] = useState('Dreadnought')
9
10 function handleShipSelection(newShipName: string) {
11 setShipName(newShipName)
12 }
13
14 return (
15 <div className="app-wrapper">
16 <button onClick={() => setCount((c) => c + 1)}>
17 Click to re-render: {count}
18 </button>
19 <ShipButtons shipName={shipName} onShipSelect={handleShipSelection} />
20 <div className="app">
21 <div className="details">
22 <ErrorBoundary fallback={<ShipError shipName={shipName} />}>
23 <Suspense fallback={<ShipFallback shipName={shipName} />}>
24 <ShipDetails shipName={shipName} />
25 </Suspense>
26 </ErrorBoundary>
27 </div>
28 </div>
29 </div>
30 )
31}
32
33function ShipButtons({
34 shipName,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected