Skip to content

Commit

Permalink
Merge branch 'main' into request-event-locals
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 1, 2024
2 parents f657ec9 + 505f86d commit 359bda5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 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 }] = createResource(fetchData)
const [data, { mutate, refetch, state }] = createResource(fetchData)
```

```tsx
const [data, { mutate, refetch }] = createResource(source, fetchData)
const [data, { mutate, refetch, state }] = 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 }] = createResource(getQuery, fetchData)
const [data, { mutate, refetch, state }] = 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 }] = createResource(() => params.id, fetchUser, {
const [data, { mutate, refetch, state }] = createResource(() => params.id, fetchUser, {
initialValue: preloadedData,
ssrLoadFrom: "initial",
})
Expand Down Expand Up @@ -197,4 +197,4 @@ function createResource<T, U>(
options?: ResourceOptions<T, U>
): ResourceReturn<T>

```
```

0 comments on commit 359bda5

Please sign in to comment.