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

v2 blog post #351

Merged
merged 16 commits into from
Sep 24, 2022
Merged

v2 blog post #351

merged 16 commits into from
Sep 24, 2022

Conversation

koba04
Copy link
Collaborator

@koba04 koba04 commented Sep 14, 2022

Todos

  • og:image
  • Authors
  • Publish date
  • Other languages

Description

I've added a blog post for v2, which only has headers for each section.
@shuding @huozhi I'll write the content later, but feel free to write the content if you want.
I'll add pages for other languages later.

  • Adding new page
  • Updating existing documentation
  • Other updates

@vercel
Copy link

vercel bot commented Sep 14, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
swr-site ✅ Ready (Inspect) Visit Preview Sep 24, 2022 at 4:34PM (UTC)

@koba04
Copy link
Collaborator Author

koba04 commented Sep 20, 2022

This still has todos, which are listed in the PR description, but this is now ready for review.

@koba04 koba04 marked this pull request as ready for review September 20, 2022 15:30
pages/blog/swr-v2.en-US.mdx Outdated Show resolved Hide resolved
pages/blog/swr-v2.en-US.mdx Outdated Show resolved Hide resolved
pages/blog/swr-v2.en-US.mdx Outdated Show resolved Hide resolved
pages/blog/swr-v2.en-US.mdx Outdated Show resolved Hide resolved

`isLoading` is a new return value that indicates if there's an ongoing request and no "loaded data". Previously, you have to check `data` and `error` are `undefined`, but now you can use the `isLoading` value.

You can improve the user experience by combining with `isLoading` and `isValidating` like this.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thinnk we can only have a simple example here, and link to the page with details of how isLoading and isValidating work.

Copy link
Collaborator Author

@koba04 koba04 Sep 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huozhi Thank you for your feedback! I've moved the details to the Understanding SWR page and simplified the isLoading example. 1cc2f14

pages/blog/swr-v2.en-US.mdx Outdated Show resolved Hide resolved
pages/blog/swr-v2.en-US.mdx Outdated Show resolved Hide resolved
pages/blog/swr-v2.en-US.mdx Outdated Show resolved Hide resolved
pages/blog/swr-v2.en-US.mdx Outdated Show resolved Hide resolved
pages/blog/swr-v2.en-US.mdx Outdated Show resolved Hide resolved
koba04 and others added 2 commits September 24, 2022 00:54
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
## Combining with isLoading and isValidating for better UX

`isLoading` and `isValidating` are similar, so you might be confused about which value you should use.
`isValidating` becomes `true` whenever there is an ongoing request, on the other hand, `isLoading` becomes `true` when there is an ongoing request and no "loaded data".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`isValidating` becomes `true` whenever there is an ongoing request, on the other hand, `isLoading` becomes `true` when there is an ongoing request and no "loaded data".
- `isValidating` becomes `true` whenever there is an ongoing request **whatever the the data is loaded or not**
- `isLoading` becomes `true` when there is an ongoing request and **data is not loaded yet**.

@@ -42,6 +43,42 @@ This pattern is to fetch data and change the key and revalidate it later with th

![A pattern for key change + previous data + fallback](/img/understanding/key-change-previous-data-fallback.svg)

## Combining with isLoading and isValidating for better UX

`isLoading` and `isValidating` are similar, so you might be confused about which value you should use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`isLoading` and `isValidating` are similar, so you might be confused about which value you should use.
Comparing to the existing `isValidating` value, `isLoading` is a new property that can help you for the more general loading cases for UX.

pages/docs/advanced/understanding.en-US.mdx Outdated Show resolved Hide resolved
}
```

![An example using the isLoading state](/img/understanding/isloading.gif)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![An example using the isLoading state](/img/understanding/isloading.gif)
![An example of using the isLoading state](/img/understanding/isloading.gif)


![An example using the isLoading state](/img/understanding/isloading.gif)

You can find the full code for this example here: https://codesandbox.io/s/swr-isloading-jtopow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can find the full code for this example here: https://codesandbox.io/s/swr-isloading-jtopow
You can find the code example [here](https://codesandbox.io/s/swr-isloading-jtopow)

pages/blog/swr-v2.en-US.mdx Show resolved Hide resolved

## What’s New

### Better React 18 Support
Copy link
Member

@huozhi huozhi Sep 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move this section to more bottom, since there's no new API change, basically improvement. We want to show users the explict changes first which can make it a bit more attractive

Copy link
Member

@huozhi huozhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Amazing work @koba04 🚀

@huozhi huozhi merged commit a910d81 into v2 Sep 24, 2022
@huozhi huozhi deleted the v2-blog branch September 24, 2022 16:36
@koba04
Copy link
Collaborator Author

koba04 commented Sep 25, 2022

@huozhi Thank you for your help!!!!

huozhi added a commit that referenced this pull request Dec 9, 2022
* Empty commit for v2 branch

* docs: optimisticData can accept a function in v2 (#333)

* docs: add mutate filter functions documentation in v2 (#340)

* Empty commit for v2 branch

* docs: add mutate filter functions documentation in v2

* remove the usage of cache.clear() and use mutate instead

* docs: add preload API documentation in v2 (#336)

* Empty commit for v2 branch

* docs: add preload API documentation in v2

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* Update pages/docs/prefetching.en-US.md

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply suggestions to other languages

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* docs: add DevTools page in v2 (#337)

* Empty commit for v2 branch

* docs: add DevTools documentation in v2

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply suggestions to other languages

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* docs: SWRConfig value as a function (#335)

* Empty commit for v2 branch

* docs: Nesting configurations with SWRConfig

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* Update pages/docs/global-configuration.en-US.md

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply suggestions to other languages

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* Fetcher no longer accepts multiple arguments in v2 (#326)

* Fetcher no longer accepts multiple arguments in v2

* Empty commit for v2 branch

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* Update pages/docs/arguments.en-US.md

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply suggestions to other languages

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* docs: add an example for preload in effect (#345)

* docs: add an example for preload in effects

* Update pages/docs/prefetching.en-US.md

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* merge examples for inside React

* Update pages/docs/prefetching.en-US.md

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply a suggestion

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* docs: add isLoading and keepPreviousData pages in v2 (#343)

* docs: add the Return Values page

* docs: add isLoading and keepPreviousData option

* docs: fix header levels

* docs: add a video for keepPreviousData

* docs: move arguments page to next to return values page

* docs: update diagrams for returning values

* docs: update the performance document to add isLoading

* docs: keep the list of return values in the options document

* use isLoading instead of !data

* translate options.md into Japanese

* docs: add a detail link for keepPreviousData

* tweak the description of isLoading

* revert to move the arguments page

* move the return values page into the advanced section

* rename the Options page to API Options

* fix links to the return values

* fix a typo

* add an excalidraw file for the state machine diagrams

* rename the page from Return Values to Understanding SWR

* rename the Options page to API

* translate Understanding SWR into Japanese

* tweak

* change /docs/options links to /docs/api

* Update pages/docs/advanced/meta.en-US.json

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* change the link of Understanding SWR

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* add documentations for useSWRMutation (#348)

* reorganize the mutation page for useSWRMutation

* write paramters and return values sections for mutation

* docs: add examples of useSWRMutation

* add an exmple to use useSWRMutation for loading data

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* docs: add notes for Suspense on SSR and React v18 in SWR v2 (#334)

* Empty commit for v2 branch

* docs: add notes for Suspense on SSR and React v18

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply suggestions to other languages

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* update other language

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* sync and refine mutate page (#350)

* sync the mutation page of other languages

* move the return values section of mutate into the API section

* Note for the shape of keys in mutate filter functions (#353)

add a note for the shape of keys in mutate filter functions

* make explicit the location of mutate (#354)

* explicit the location of mutate

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply feedback to other languages

* add more descriptiong to mutation

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* v2 blog post (#351)

* add the v2 blog page

* update the description

* add the migration guide section

* write more section for what's new

* write changes of highlights

* add demo videos in the v2 blog and links to the CodeSandbox

* tweak

* add braking changes for mutate multiple items

* update description

* add isMutating into the example for useSWRMutation

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* Update pages/blog/swr-v2.en-US.mdx

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* move the details of isLoading and isValidating to the Userstanding SWR page

* tweak wording

* add authors

* add og image

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* use link for codesandbox example (#355)

* sync translations (#356)

* sync the translation docs

* fix Author's link

* remove copy from a file name

* fix: typos in v2 docs (#357)

* fix: the hook name of useSWRMutation example

* fix: optimisticData examples

* Add onDiscarded option (#371)

add onDiscarded option

* V2 docs improvements (#361)

* blog improvements

* update

* update blog post

* update mutation

* update

* docs: change the build target in the v2 blogdocs:  (#381)

docs: change the build target in the v2 blog

* Add functional rollbackOnError description (#377)

* Add functional rollbackOnError description

* fix typo

* docs: translate v2 blog into Japanese (#383)

* docs: translate v2 updates in Japanese (#384)

* docs: translate v2 updates into Japanese

* tweak

* Fix case for section title (#387)

* Update card and description for the v2 blog post (#388)

update card and description

* Rename laggy ui to preserving previous state (#389)

* Rename laggy ui to preserving previous state

* fix

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: Shu Ding <g@shud.in>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants