File tree Expand file tree Collapse file tree
src/content/reference/react Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,15 +233,43 @@ Fetching data inside an Effect does not activate the boundary. Suspense can't de
233233
234234<Sandpack >
235235
236- ``` js
236+ ``` js src/App.js hidden
237+ import { useState } from ' react' ;
238+ import ArtistPage from ' ./ArtistPage.js' ;
239+
240+ export default function App () {
241+ const [show , setShow ] = useState (false );
242+ if (show) {
243+ return (
244+ < ArtistPage
245+ artist= {{
246+ id: ' the-beatles' ,
247+ name: ' The Beatles' ,
248+ }}
249+ / >
250+ );
251+ } else {
252+ return (
253+ < button onClick= {() => setShow (true )}>
254+ Open The Beatles artist page
255+ < / button>
256+ );
257+ }
258+ }
259+ ```
260+
261+ ``` js src/ArtistPage.js active
237262import { Suspense } from ' react' ;
238263import EffectAlbums from ' ./EffectAlbums.js' ;
239264
240- export default function App ( ) {
265+ export default function ArtistPage ({ artist } ) {
241266 return (
242- < Suspense fallback= {< Loading / > }>
243- < EffectAlbums artistId= " the-beatles" / >
244- < / Suspense>
267+ <>
268+ < h1> {artist .name }< / h1>
269+ < Suspense fallback= {< Loading / > }>
270+ < EffectAlbums artistId= {artist .id } / >
271+ < / Suspense>
272+ < / >
245273 );
246274}
247275
@@ -250,7 +278,7 @@ function Loading() {
250278}
251279```
252280
253- ``` js src/EffectAlbums.js active
281+ ``` js src/EffectAlbums.js
254282import { useState , useEffect } from ' react' ;
255283import { fetchData } from ' ./data.js' ;
256284
You can’t perform that action at this time.
0 commit comments