Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update createResource, add "state" field. #918

Merged
merged 37 commits into from
Dec 1, 2024
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9fa4e2c
Update createResource, add "state" field.
klequis Oct 10, 2024
271d06e
Update create-resource.mdx
klequis Oct 10, 2024
f9af025
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 13, 2024
22d2d8f
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 14, 2024
b15f695
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 15, 2024
748550c
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 16, 2024
24d517d
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 17, 2024
c9d4adf
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 24, 2024
73fafc4
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 24, 2024
8b08d95
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 24, 2024
49169f6
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 24, 2024
9d64740
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 24, 2024
2b2eeac
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 30, 2024
dcd957f
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 30, 2024
ad523f9
Merge branch 'main' into patch-7
kodiakhq[bot] Oct 31, 2024
dfec603
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 3, 2024
573e482
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 3, 2024
2a80aed
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 3, 2024
3441b57
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 4, 2024
32d4187
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 4, 2024
c4d3d22
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 11, 2024
c1dda7f
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 11, 2024
6a4efe0
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 20, 2024
d963c4e
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 21, 2024
2d8474a
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 23, 2024
e462e43
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 24, 2024
f01a1f6
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 24, 2024
3441299
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 24, 2024
eb5108d
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 24, 2024
48c3fa4
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 24, 2024
8024d37
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 25, 2024
d17e78f
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 25, 2024
d22765c
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 26, 2024
802fb04
Merge branch 'main' into patch-7
kodiakhq[bot] Nov 26, 2024
6b3dd33
Merge branch 'main' into patch-7
kodiakhq[bot] Dec 1, 2024
46582fc
Merge branch 'main' into patch-7
kodiakhq[bot] Dec 1, 2024
9f45f30
Merge branch 'main' into patch-7
kodiakhq[bot] Dec 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>

```
```
Loading