Skip to content

Commit 3998b9a

Browse files
committed
Add DevTools to each example.
1 parent 4bf5c49 commit 3998b9a

File tree

19 files changed

+116
-60
lines changed

19 files changed

+116
-60
lines changed

examples/basic-fetch/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"dependencies": {
66
"react": "^16.8.6",
77
"react-async": "latest",
8+
"react-async-devtools": "latest",
89
"react-dom": "^16.8.6",
910
"react-scripts": "^3.0.1"
1011
},

examples/basic-fetch/src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react"
22
import Async from "react-async"
3+
import DevTools from "react-async-devtools"
34
import ReactDOM from "react-dom"
45
import "./index.css"
56

@@ -26,7 +27,8 @@ const UserDetails = ({ data }) => (
2627

2728
const App = () => (
2829
<>
29-
<Async promiseFn={loadUser} userId={1}>
30+
<DevTools />
31+
<Async promiseFn={loadUser} userId={1} debugLabel="User 1">
3032
{({ data, error, isPending }) => {
3133
if (isPending) return <UserPlaceholder />
3234
if (error) return <p>{error.message}</p>
@@ -35,7 +37,7 @@ const App = () => (
3537
}}
3638
</Async>
3739

38-
<Async promiseFn={loadUser} userId={2}>
40+
<Async promiseFn={loadUser} userId={2} debugLabel="User 2">
3941
<Async.Pending>
4042
<UserPlaceholder />
4143
</Async.Pending>

examples/basic-hook/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"dependencies": {
66
"react": "16.8.5",
77
"react-async": "latest",
8+
"react-async-devtools": "latest",
89
"react-dom": "16.8.5",
910
"react-scripts": "2.1.8"
1011
},

examples/basic-hook/src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react"
22
import { useAsync } from "react-async"
33
import ReactDOM from "react-dom"
4+
import DevTools from "react-async-devtools"
45
import "./index.css"
56

67
const loadUser = ({ userId }) =>
@@ -26,7 +27,11 @@ const UserDetails = ({ data }) => (
2627
)
2728

2829
const User = ({ userId }) => {
29-
const { data, error, isPending } = useAsync({ promiseFn: loadUser, userId })
30+
const { data, error, isPending } = useAsync({
31+
promiseFn: loadUser,
32+
debugLabel: `User ${userId}`,
33+
userId,
34+
})
3035
if (isPending) return <UserPlaceholder />
3136
if (error) return <p>{error.message}</p>
3237
if (data) return <UserDetails data={data} />
@@ -35,6 +40,7 @@ const User = ({ userId }) => {
3540

3641
const App = () => (
3742
<>
43+
<DevTools />
3844
<User userId={1} />
3945
<User userId={2} />
4046
</>

examples/custom-instance/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"dependencies": {
66
"react": "^16.8.5",
77
"react-async": "latest",
8+
"react-async-devtools": "latest",
89
"react-dom": "^16.8.5",
910
"react-scripts": "2.1.8"
1011
},

examples/custom-instance/src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react"
22
import { createInstance } from "react-async"
3+
import DevTools from "react-async-devtools"
34
import ReactDOM from "react-dom"
45
import "./index.css"
56

@@ -28,16 +29,16 @@ const UserDetails = ({ data }) => (
2829

2930
const App = () => (
3031
<>
31-
<AsyncUser userId={1}>
32+
<DevTools />
33+
<AsyncUser userId={1} debugLabel="User 1">
3234
{({ data, error, isPending }) => {
3335
if (isPending) return <UserPlaceholder />
3436
if (error) return <p>{error.message}</p>
3537
if (data) return <UserDetails data={data} />
3638
return null
3739
}}
3840
</AsyncUser>
39-
40-
<AsyncUser userId={2}>
41+
<AsyncUser userId={2} debugLabel="User 2">
4142
<AsyncUser.Pending>
4243
<UserPlaceholder />
4344
</AsyncUser.Pending>

examples/movie-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"private": true,
55
"dependencies": {
66
"react": "^16.8.5",
7-
"react-async": "5.1.2",
7+
"react-async": "latest",
8+
"react-async-devtools": "latest",
89
"react-dom": "^16.8.5",
910
"react-scripts": "2.1.8"
1011
},

examples/movie-app/src/App.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const TopMovies = ({ handleSelect }) => (
6161
🍿
6262
</span>
6363
</h1>
64-
<Async promiseFn={fetchMovies}>
64+
<Async promiseFn={fetchMovies} debugLabel={`Movies`}>
6565
<Async.Pending>
6666
<p>Loading...</p>
6767
</Async.Pending>
@@ -98,7 +98,12 @@ const Details = ({ onBack, id }) => (
9898
👈
9999
</span>
100100
</button>
101-
<Async promiseFn={fetchMovieDetails} id={id} onResolve={console.log}>
101+
<Async
102+
promiseFn={fetchMovieDetails}
103+
debugLabel={`Details ${id}`}
104+
id={id}
105+
onResolve={console.log}
106+
>
102107
<Async.Pending>
103108
<p>Loading...</p>
104109
</Async.Pending>
@@ -125,7 +130,12 @@ const Details = ({ onBack, id }) => (
125130
</div>
126131
</div>
127132
<div className="reviews">
128-
<Async promiseFn={fetchMovieReviews} id={id} onResolve={console.log}>
133+
<Async
134+
promiseFn={fetchMovieReviews}
135+
debugLabel={`Reviews ${id}`}
136+
id={id}
137+
onResolve={console.log}
138+
>
129139
<Async.Pending>
130140
<p>Loading...</p>
131141
</Async.Pending>

examples/movie-app/src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import React from "react"
2+
import DevTools from "react-async-devtools"
23
import ReactDOM from "react-dom"
34
import "./index.css"
45
import App from "./App"
56
// import * as serviceWorker from './serviceWorker';
67

7-
ReactDOM.render(<App />, document.getElementById("root"))
8+
ReactDOM.render(
9+
<>
10+
<DevTools />
11+
<App />
12+
</>,
13+
document.getElementById("root")
14+
)
815

916
// If you want your app to work offline and load faster, you can change
1017
// unregister() to register() below. Note this comes with some pitfalls.

examples/with-abortcontroller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"dependencies": {
66
"react": "16.8.5",
77
"react-async": "latest",
8+
"react-async-devtools": "latest",
89
"react-dom": "16.8.5",
910
"react-scripts": "2.1.8"
1011
},

0 commit comments

Comments
 (0)