Skip to content
This repository was archived by the owner on Aug 3, 2023. It is now read-only.

Commit 042a79a

Browse files
authored
Merge pull request #141 from jamesplease/update-examples
Update examples to always check for data
2 parents 0ecefd5 + 13c57a9 commit 042a79a

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ class App extends Component {
9090
return <div>The request did not succeed.</div>;
9191
}
9292

93-
return (
94-
<div>
95-
<div>Post ID: {data.id}</div>
96-
<div>Post Title: {data.title}</div>
97-
</div>
98-
);
93+
if (data) {
94+
return (
95+
<div>
96+
<div>Post ID: {data.id}</div>
97+
<div>Post Title: {data.title}</div>
98+
</div>
99+
);
100+
}
101+
102+
return null;
99103
}}
100104
</Fetch>
101105
);
@@ -350,7 +354,11 @@ about the response, such as its status code.
350354
};
351355
}}>
352356
{({ data }) => {
353-
<div>{data.countryName}</div>;
357+
if (data) {
358+
return <div>{data.countryName}</div>;
359+
}
360+
361+
return null;
354362
}}
355363
</Fetch>
356364
```
@@ -371,7 +379,11 @@ about the response, such as its status code.
371379
};
372380
}}>
373381
{({ data }) => {
374-
<div>{data.countryName}</div>;
382+
if (data) {
383+
return <div>{data.countryName}</div>;
384+
}
385+
386+
return null;
375387
}}
376388
</Fetch>
377389
```

0 commit comments

Comments
 (0)