Skip to content

Commit dcd957f

Browse files
Merge branch 'main' into patch-7
2 parents 2b2eeac + 8190d27 commit dcd957f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/routes/guides/fetching-data.mdx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ When there is a change in the source signal, an internal fetch process is trigge
3434
```jsx
3535
import { createSignal, createResource, Switch, Match, Show } from "solid-js";
3636

37-
const fetchUser = async (id) =>
38-
{
37+
const fetchUser = async (id) => {
3938
const response = await fetch(`https://swapi.dev/api/people/${id}/`);
4039
return response.json();
4140
}
@@ -63,7 +62,6 @@ function App() {
6362
<div>{JSON.stringify(user())}</div>
6463
</Match>
6564
</Switch>
66-
6765
</div>
6866
);
6967
}
@@ -91,7 +89,7 @@ import { createSignal, createResource, Switch, Match, Suspense } from "solid-js"
9189
const fetchUser = async (id) => {
9290
const response = await fetch(`https://swapi.dev/api/people/${id}/`);
9391
return response.json();
94-
}
92+
}
9593

9694
function App() {
9795
const [userId, setUserId] = createSignal();
@@ -106,7 +104,6 @@ function App() {
106104
onInput={(e) => setUserId(e.currentTarget.value)}
107105
/>
108106
<Suspense fallback={<div>Loading...</div>}>
109-
110107
<Switch>
111108
<Match when={user.error}>
112109
<span>Error: {user.error.message}</span>
@@ -152,15 +149,19 @@ function TodoList() {
152149
<>
153150
<ul>
154151
<For each={tasks()}>
155-
{task => (
152+
{(task) => (
156153
<li>{task.name}</li>
157154
)}
158155
</For>
159156
</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>
164165
</>
165166
);
166167
}

0 commit comments

Comments
 (0)