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

Function ShipDetails

exercises/01.fetching/02.problem.errors/index.tsx:34–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32)
33
34function ShipDetails() {
35 // 🐨 if there was an error, throw it.
36 if (!ship) throw shipPromise
37
38 return (
39 <div className="ship-info">
40 <div className="ship-info__img-wrapper">
41 <img
42 src={getImageUrlForShip(ship.name, { size: 200 })}
43 alt={ship.name}
44 />
45 </div>
46 <section>
47 <h2>
48 {ship.name}
49 <sup>
50 {ship.topSpeed} <small>lyh</small>
51 </sup>
52 </h2>
53 </section>
54 <section>
55 {ship.weapons.length ? (
56 <ul>
57 {ship.weapons.map((weapon) => (
58 <li key={weapon.name}>
59 <label>{weapon.name}</label>:{' '}
60 <span>
61 {weapon.damage} <small>({weapon.type})</small>
62 </span>
63 </li>
64 ))}
65 </ul>
66 ) : (
67 <p>NOTE: This ship is not equipped with any weapons.</p>
68 )}
69 </section>
70 <small className="ship-info__fetch-time">{ship.fetchedAt}</small>
71 </div>
72 )
73}
74
75function ShipFallback() {
76 return (

Callers

nothing calls this directly

Calls 1

getImageUrlForShipFunction · 0.90

Tested by

no test coverage detected