Skip to content

Commit efea2b0

Browse files
koba04huozhishuding
authored
Docs for v2.0 (#325)
* 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 <[email protected]> * Update pages/docs/prefetching.en-US.md Co-authored-by: Jiachi Liu <[email protected]> * apply suggestions to other languages Co-authored-by: Jiachi Liu <[email protected]> * 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 <[email protected]> * apply suggestions to other languages Co-authored-by: Jiachi Liu <[email protected]> * 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 <[email protected]> * Update pages/docs/global-configuration.en-US.md Co-authored-by: Jiachi Liu <[email protected]> * apply suggestions to other languages Co-authored-by: Jiachi Liu <[email protected]> * 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 <[email protected]> * Update pages/docs/arguments.en-US.md Co-authored-by: Jiachi Liu <[email protected]> * apply suggestions to other languages Co-authored-by: Jiachi Liu <[email protected]> * 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 <[email protected]> * merge examples for inside React * Update pages/docs/prefetching.en-US.md Co-authored-by: Jiachi Liu <[email protected]> * apply a suggestion Co-authored-by: Jiachi Liu <[email protected]> * 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 <[email protected]> * change the link of Understanding SWR Co-authored-by: Jiachi Liu <[email protected]> * 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 <[email protected]> Co-authored-by: Jiachi Liu <[email protected]> * 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 <[email protected]> * apply suggestions to other languages * Apply suggestions from code review Co-authored-by: Jiachi Liu <[email protected]> * update other language Co-authored-by: Jiachi Liu <[email protected]> * 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 <[email protected]> * apply feedback to other languages * add more descriptiong to mutation Co-authored-by: Jiachi Liu <[email protected]> * 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 <[email protected]> * Update pages/blog/swr-v2.en-US.mdx Co-authored-by: Jiachi Liu <[email protected]> * move the details of isLoading and isValidating to the Userstanding SWR page * tweak wording * add authors * add og image Co-authored-by: Jiachi Liu <[email protected]> * 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 <[email protected]> Co-authored-by: Shu Ding <[email protected]>
1 parent 57991d1 commit efea2b0

File tree

151 files changed

+15527
-2293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+15527
-2293
lines changed

components/excalidraw/state-machine.excalidraw

+5,744
Large diffs are not rendered by default.

components/video.js

+35-22
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,65 @@
1-
import { useRef, useCallback, useEffect } from 'react'
2-
import { useInView } from 'react-intersection-observer'
3-
import 'intersection-observer'
1+
import { useRef, useCallback, useEffect } from "react";
2+
import { useInView } from "react-intersection-observer";
3+
import "intersection-observer";
44

55
export default ({ src, caption, ratio }) => {
66
const [inViewRef, inView] = useInView({
77
threshold: 1,
8-
})
9-
const videoRef = useRef()
8+
});
9+
const videoRef = useRef();
1010

1111
const setRefs = useCallback(
1212
(node) => {
1313
// Ref's from useRef needs to have the node assigned to `current`
14-
videoRef.current = node
14+
videoRef.current = node;
1515
// Callback refs, like the one from `useInView`, is a function that takes the node as an argument
16-
inViewRef(node)
16+
inViewRef(node);
1717

1818
if (node) {
19-
node.addEventListener('click', function () {
19+
node.addEventListener("click", function () {
2020
if (this.paused) {
21-
this.play()
21+
this.play();
2222
} else {
23-
this.pause()
23+
this.pause();
2424
}
25-
})
25+
});
2626
}
2727
},
2828
[inViewRef]
29-
)
29+
);
3030

3131
useEffect(() => {
3232
if (!videoRef || !videoRef.current) {
33-
return
33+
return;
3434
}
3535

3636
if (inView) {
37-
videoRef.current.play()
37+
videoRef.current.play();
3838
} else {
39-
videoRef.current.pause()
39+
videoRef.current.pause();
4040
}
41-
}, [inView])
41+
}, [inView]);
4242

4343
return (
44-
<div style={{ position: 'relative', margin: '2rem 1rem' }}>
45-
<div style={{ paddingBottom: ratio * 100 + '%' }}/>
46-
<video style={{ position: 'absolute', top: 0, left: 0 }} loop muted autoPlay playsInline ref={setRefs}>
44+
<div style={{ position: "relative", margin: "2rem 1rem" }}>
45+
<div style={{ paddingBottom: ratio * 100 + "%" }} />
46+
<video
47+
style={{ position: "absolute", top: 0, left: 0 }}
48+
loop
49+
muted
50+
autoPlay
51+
playsInline
52+
ref={setRefs}
53+
>
4754
<source src={src} type="video/mp4" />
4855
</video>
49-
{caption && <figcaption style={{ fontSize: '.9rem', textAlign: 'center' }}>{caption}</figcaption>}
56+
{caption && (
57+
<figcaption
58+
style={{ fontSize: ".9rem", textAlign: "center", marginTop: "1em" }}
59+
>
60+
{caption}
61+
</figcaption>
62+
)}
5063
</div>
51-
)
52-
}
64+
);
65+
};

next.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ module.exports = withNextra({
3232
destination: "/docs/advanced/cache",
3333
statusCode: 301,
3434
},
35+
{
36+
source: "/docs/options",
37+
destination: "/docs/api",
38+
statusCode: 301
39+
},
3540
{
3641
source: "/change-log",
3742
destination: "/docs/change-log",

pages/blog/meta.en-US.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"swr-v2": "Announcing SWR 2.0",
23
"swr-v1": "Announcing SWR 1.0"
34
}

pages/blog/meta.es-ES.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"swr-v2": "Announcing SWR 2.0",
23
"swr-v1": "Announcing SWR 1.0"
34
}

pages/blog/meta.ja.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"swr-v2": "SWR 2.0 の発表",
23
"swr-v1": "SWR 1.0 の発表"
34
}

pages/blog/meta.ko.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"swr-v2": "Announcing SWR 2.0",
23
"swr-v1": "SWR 1.0 알림"
34
}

pages/blog/meta.pt-BR.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
{
2-
"swr-v1": "Anunciando SWR 1.0"
3-
}
1+
{
2+
"swr-v2": "Announcing SWR 2.0",
3+
"swr-v1": "Anunciando SWR 1.0"
4+
}

pages/blog/meta.ru.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"swr-v2": "Announcing SWR 2.0",
23
"swr-v1": "Представляем SWR 1.0"
34
}

pages/blog/meta.zh-CN.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"swr-v2": "Announcing SWR 2.0",
23
"swr-v1": "SWR 1.0 发布"
34
}

0 commit comments

Comments
 (0)