Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 14, 2024
2 parents bc698c6 + 1f0d66b commit b802c7d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/routes/reference/basic-reactivity/create-resource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ There are two ways to use `createResource`: you can pass the fetcher function as
The source signal will retrigger the fetcher whenever it changes, and its value will be passed to the fetcher.

```tsx
const [data, { mutate, refetch, state }] = createResource(fetchData)
const [data, { mutate, refetch }] = createResource(fetchData)
```

```tsx
const [data, { mutate, refetch, state }] = createResource(source, fetchData)
const [data, { mutate, refetch }] = createResource(source, fetchData)
```

In these snippets, the fetcher is the function `fetchData`, and `data()` is undefined until `fetchData` finishes resolving.
Expand Down Expand Up @@ -49,7 +49,7 @@ async function fetchData(source, { value, refetching }) {
// or equal to the optional data passed: `refetch(info)`
}

const [data, { mutate, refetch, state }] = createResource(getQuery, fetchData)
const [data, { mutate, refetch }] = createResource(getQuery, fetchData)

// read value
data()
Expand Down Expand Up @@ -102,7 +102,7 @@ You can use the new `ssrLoadFrom` option for this.
Instead of using the default `server` value, you can pass `initial` and the resource will use `initialValue` as if it were the result of the first fetch for both SSR and hydration.

```tsx
const [data, { mutate, refetch, state }] = createResource(() => params.id, fetchUser, {
const [data, { mutate, refetch }] = createResource(() => params.id, fetchUser, {
initialValue: preloadedData,
ssrLoadFrom: "initial",
})
Expand Down

0 comments on commit b802c7d

Please sign in to comment.