@@ -34,8 +34,7 @@ When there is a change in the source signal, an internal fetch process is trigge
34
34
``` jsx
35
35
import { createSignal , createResource , Switch , Match , Show } from " solid-js" ;
36
36
37
- const fetchUser = async (id ) =>
38
- {
37
+ const fetchUser = async (id ) => {
39
38
const response = await fetch (` https://swapi.dev/api/people/${ id} /` );
40
39
return response .json ();
41
40
}
@@ -63,7 +62,6 @@ function App() {
63
62
< div> {JSON .stringify (user ())}< / div>
64
63
< / Match>
65
64
< / Switch>
66
-
67
65
< / div>
68
66
);
69
67
}
@@ -91,7 +89,7 @@ import { createSignal, createResource, Switch, Match, Suspense } from "solid-js"
91
89
const fetchUser = async (id ) => {
92
90
const response = await fetch (` https://swapi.dev/api/people/${ id} /` );
93
91
return response .json ();
94
- }
92
+ }
95
93
96
94
function App () {
97
95
const [userId , setUserId ] = createSignal ();
@@ -106,7 +104,6 @@ function App() {
106
104
onInput= {(e ) => setUserId (e .currentTarget .value )}
107
105
/ >
108
106
< Suspense fallback= {< div> Loading... < / div> }>
109
-
110
107
< Switch>
111
108
< Match when= {user .error }>
112
109
< span> Error : {user .error .message }< / span>
@@ -152,15 +149,19 @@ function TodoList() {
152
149
<>
153
150
< ul>
154
151
< For each= {tasks ()}>
155
- {task => (
152
+ {( task ) => (
156
153
< li> {task .name }< / li>
157
154
)}
158
155
< / For>
159
156
< / ul>
160
- < button onClick= {() => {
161
- mutate ((todos ) => [... todos, " do new task" ]) // add todo for user
162
- // make a call to send to database
163
- }}> Add Task< / button>
157
+ < button
158
+ onClick= {() => {
159
+ mutate ((todos ) => [... todos, " do new task" ]); // add todo for user
160
+ // make a call to send to database
161
+ }}
162
+ >
163
+ Add Task
164
+ < / button>
164
165
< / >
165
166
);
166
167
}
0 commit comments