Skip to content

Commit b8708a1

Browse files
committed
Merge branch 'master' into size-limit-action
2 parents e75b140 + eb0128e commit b8708a1

File tree

9 files changed

+83
-63
lines changed

9 files changed

+83
-63
lines changed

CONTRIBUTING.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,59 @@ Before opening an issue, please search the [issue tracker](https://github.com/re
88

99
Please ask any general and implementation specific questions on [Stack Overflow with a Redux Toolkit tag](http://stackoverflow.com/questions/tagged/redux-toolkit?sort=votes&pageSize=50) for support.
1010

11-
## New Features
11+
We ask you to do this because StackOverflow has a much better job at keeping popular questions visible. Unfortunately good answers get lost and outdated on GitHub.
1212

13-
Please open an issue with a proposal for a new feature or refactoring before starting on the work. We don't want you to waste your efforts on a pull request that we won't want to accept.
13+
If your question gets closed or you don't get a reply after a few days, consider opening a [discussion](https://github.com/reduxjs/redux-toolkit/discussions) or joining the [Reactiflux](https://discord.gg/reactiflux) discord server and asking in the #redux channel.
14+
15+
### Help Us Help You
16+
17+
On both websites, it is a good idea to structure your code and question in a way that is easy to read to help people to answer it. For example, we encourage you to use syntax highlighting, indentation, and split text in paragraphs.
18+
19+
Please keep in mind that people spend their free time trying to help you. You can make it easier for them if you provide versions of the relevant libraries and a runnable small project reproducing your issue. You can put your code on [JSBin](https://jsbin.com) or, for bigger projects, on GitHub. Make sure all the necessary dependencies are declared in `package.json` so anyone can run `npm install && npm start` and reproduce your issue.
20+
21+
## Ways You Can Contribute
22+
23+
There are several ways you can contribute to the repository. Instead of developing a feature or fixing a bug, you can also contribute by updating or writing [documentation](https://github.com/reduxjs/redux-toolkit/tree/master/docs) for a specific feature or implementation if you know you are good with documentation. Alternatively, you can add [examples](https://github.com/reduxjs/redux-toolkit/tree/master/examples) of any 3rd party implementation like GraphQL or React (just an example) that would help users to understand and easily integrate Redux Toolkit with that specific framework and library.
1424

1525
## Getting started
1626

1727
Visit the [Issue tracker](https://github.com/reduxjs/redux-toolkit/issues) to find a list of open issues that need attention.
1828

29+
### Bugs and Improvements
30+
31+
We use the [Issue tracker](https://github.com/reduxjs/redux-toolkit/issues) to keep track of bugs and improvements to Redux Toolkit itself, its examples, and the documentation. We encourage you to open issues to discuss improvements, architecture, theory, internal implementation, etc. If a topic has been discussed before, we will ask you to join the previous discussion.
32+
33+
### New Features
34+
35+
Please open an [issue](https://github.com/reduxjs/redux-toolkit/issues) with a proposal for a new feature or refactoring before starting on the work. We don't want you to waste your efforts on a pull request that we won't want to accept.
36+
1937
### Fork the repository
2038

2139
Please use the GitHub UI to [fork this repository](https://github.com/reduxjs/redux-toolkit) (_read more about [Forking a repository](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo)_). Redux Toolkit has forked builds enabled in the CI, so you will see the build status of your fork's branch.
2240

41+
![Fork Button](https://docs.github.com/assets/cb-40742/mw-1440/images/help/repository/fork-button.webp)
42+
43+
Fork, then clone the repo:
44+
45+
```sh
46+
git clone https://github.com/your-username/redux-toolkit.git
47+
```
48+
2349
### Install
2450

2551
```bash
2652
$ cd redux-toolkit
2753
$ yarn
2854
```
2955

56+
### Build
57+
58+
You can build the packages with the following command:
59+
60+
```
61+
yarn build
62+
```
63+
3064
### Tests
3165

3266
You can run tests for all packages with:
@@ -41,14 +75,6 @@ To continuously watch and run tests, run the following:
4175
yarn test --watch
4276
```
4377

44-
### Build
45-
46-
You can build the packages with the following command:
47-
48-
```
49-
yarn build
50-
```
51-
5278
## Git workflow / Submitting Changes
5379

5480
- Open a new issue in the [Issue tracker](https://github.com/reduxjs/redux-toolkit/issues).

docs/api/createSlice.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ create.preparedReducer(
240240

241241
Creates an async thunk instead of an action creator.
242242

243-
:::warning Setup
243+
:::caution Setup
244244

245245
To avoid pulling `createAsyncThunk` into the bundle size of `createSlice` by default, some extra setup is required to use `create.asyncThunk`.
246246

docs/rtk-query/api/created-api/hooks.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ type UseQuery = (
251251

252252
type UseQueryOptions = {
253253
pollingInterval?: number
254+
skipPollingIfUnfocused?: boolean
254255
refetchOnReconnect?: boolean
255256
refetchOnFocus?: boolean
256257
skip?: boolean
@@ -445,6 +446,7 @@ type UseQuerySubscriptionOptions = {
445446
skip?: boolean
446447
refetchOnMountOrArgChange?: boolean | number
447448
pollingInterval?: number
449+
skipPollingIfUnfocused?: boolean
448450
refetchOnReconnect?: boolean
449451
refetchOnFocus?: boolean
450452
}
@@ -485,6 +487,7 @@ type UseLazyQuery = (
485487

486488
type UseLazyQueryOptions = {
487489
pollingInterval?: number
490+
skipPollingIfUnfocused?: boolean
488491
refetchOnReconnect?: boolean
489492
refetchOnFocus?: boolean
490493
selectFromResult?: (result: UseQueryStateDefaultResult) => any
@@ -555,6 +558,7 @@ type UseLazyQuerySubscription = (
555558

556559
type UseLazyQuerySubscriptionOptions = {
557560
pollingInterval?: number
561+
skipPollingIfUnfocused?: boolean
558562
refetchOnReconnect?: boolean
559563
refetchOnFocus?: boolean
560564
}

docs/rtk-query/usage/polling.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,21 @@ description: 'RTK Query > Usage > Polling: re-fetching data on a timer'
1414

1515
Polling gives you the ability to have a 'real-time' effect by causing a query to run at a specified interval. To enable polling for a query, pass a `pollingInterval` to the `useQuery` hook or action creator with an interval in milliseconds:
1616

17+
:::tip
18+
Polling additionally has the ability to skip sending requests while the window is out of focus. To enable this behavior, pass `skipPollingIfUnfocused: true` to the `useQuery` hook or action creator.
19+
20+
_Note: `skipPollingIfUnfocused` requires [`setupListeners`](../api/setupListeners.mdx) to have been called._
21+
:::
22+
1723
```tsx no-transpile title="src/Pokemon.tsx" no-transpile
1824
import * as React from 'react'
1925
import { useGetPokemonByNameQuery } from './services/pokemon'
2026

2127
export const Pokemon = ({ name }: { name: string }) => {
22-
// Automatically refetch every 3s
28+
// Automatically refetch every 3s unless the window is out of focus
2329
const { data, status, error, refetch } = useGetPokemonByNameQuery(name, {
2430
pollingInterval: 3000,
31+
skipPollingIfUnfocused: true,
2532
})
2633

2734
return <div>{data}</div>

packages/rtk-query-codegen-openapi/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@types/jest": "^27",
4040
"@types/lodash": "^4.14.165",
4141
"@types/node": "^14.14.12",
42+
"@types/node-fetch": "^2.6.11",
4243
"@types/prettier": "^2.1.6",
4344
"@types/semver": "^7.3.9",
4445
"babel-jest": "^26.6.3",
@@ -49,6 +50,7 @@
4950
"husky": "^4.3.6",
5051
"jest": "^29",
5152
"msw": "^0.40.2",
53+
"node-fetch": "^2.7.0",
5254
"openapi-types": "^9.1.0",
5355
"pretty-quick": "^3.1.0",
5456
"ts-jest": "^29",

packages/toolkit/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,7 @@ RTK Query includes these APIs:
104104
- `setupListeners()`: A utility used to enable refetchOnMount and refetchOnReconnect behaviors.
105105

106106
See the [**RTK Query Overview**](https://redux-toolkit.js.org/rtk-query/overview) page for more details on what RTK Query is, what problems it solves, and how to use it.
107+
108+
## Contributing
109+
110+
Please refer to our [contributing guide](/CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Redux Toolkit.

packages/toolkit/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@types/json-stringify-safe": "^5.0.0",
6060
"@types/nanoid": "^2.1.0",
6161
"@types/node": "^20.11.0",
62+
"@types/node-fetch": "^2.6.11",
6263
"@types/query-string": "^6.3.0",
6364
"@types/react": "^18.0.12",
6465
"@types/react-dom": "^18.0.5",
@@ -82,7 +83,7 @@
8283
"jsdom": "^21.0.0",
8384
"json-stringify-safe": "^5.0.1",
8485
"msw": "^2.1.4",
85-
"node-fetch": "^3.3.2",
86+
"node-fetch": "^2.7.0",
8687
"prettier": "^3.2.4",
8788
"query-string": "^7.0.1",
8889
"rimraf": "^3.0.2",

packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ describe('fetchBaseQuery', () => {
10031003

10041004
expect(result?.error).toEqual({
10051005
status: 'TIMEOUT_ERROR',
1006-
error: 'AbortError: The operation was aborted.',
1006+
error: expect.stringMatching(/^AbortError:/),
10071007
})
10081008
})
10091009
})
@@ -1121,7 +1121,7 @@ describe('timeout', () => {
11211121

11221122
expect(result?.error).toEqual({
11231123
status: 'TIMEOUT_ERROR',
1124-
error: 'AbortError: The operation was aborted.',
1124+
error: expect.stringMatching(/^AbortError:/),
11251125
})
11261126
})
11271127
})

yarn.lock

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7456,6 +7456,7 @@ __metadata:
74567456
"@types/json-stringify-safe": ^5.0.0
74577457
"@types/nanoid": ^2.1.0
74587458
"@types/node": ^20.11.0
7459+
"@types/node-fetch": ^2.6.11
74597460
"@types/query-string": ^6.3.0
74607461
"@types/react": ^18.0.12
74617462
"@types/react-dom": ^18.0.5
@@ -7480,7 +7481,7 @@ __metadata:
74807481
jsdom: ^21.0.0
74817482
json-stringify-safe: ^5.0.1
74827483
msw: ^2.1.4
7483-
node-fetch: ^3.3.2
7484+
node-fetch: ^2.7.0
74847485
prettier: ^3.2.4
74857486
query-string: ^7.0.1
74867487
redux: ^5.0.1
@@ -7747,6 +7748,7 @@ __metadata:
77477748
"@types/jest": ^27
77487749
"@types/lodash": ^4.14.165
77497750
"@types/node": ^14.14.12
7751+
"@types/node-fetch": ^2.6.11
77507752
"@types/prettier": ^2.1.6
77517753
"@types/semver": ^7.3.9
77527754
babel-jest: ^26.6.3
@@ -7758,6 +7760,7 @@ __metadata:
77587760
husky: ^4.3.6
77597761
jest: ^29
77607762
msw: ^0.40.2
7763+
node-fetch: ^2.7.0
77617764
oazapfts: ^4.8.0
77627765
openapi-types: ^9.1.0
77637766
prettier: ^2.2.1
@@ -8882,6 +8885,16 @@ __metadata:
88828885
languageName: node
88838886
linkType: hard
88848887

8888+
"@types/node-fetch@npm:^2.6.11":
8889+
version: 2.6.11
8890+
resolution: "@types/node-fetch@npm:2.6.11"
8891+
dependencies:
8892+
"@types/node": "*"
8893+
form-data: ^4.0.0
8894+
checksum: 180e4d44c432839bdf8a25251ef8c47d51e37355ddd78c64695225de8bc5dc2b50b7bb855956d471c026bb84bd7295688a0960085e7158cbbba803053492568b
8895+
languageName: node
8896+
linkType: hard
8897+
88858898
"@types/node@npm:*, @types/node@npm:^17.0.5":
88868899
version: 17.0.45
88878900
resolution: "@types/node@npm:17.0.45"
@@ -13703,13 +13716,6 @@ __metadata:
1370313716
languageName: node
1370413717
linkType: hard
1370513718

13706-
"data-uri-to-buffer@npm:^4.0.0":
13707-
version: 4.0.1
13708-
resolution: "data-uri-to-buffer@npm:4.0.1"
13709-
checksum: 0d0790b67ffec5302f204c2ccca4494f70b4e2d940fea3d36b09f0bb2b8539c2e86690429eb1f1dc4bcc9e4df0644193073e63d9ee48ac9fce79ec1506e4aa4c
13710-
languageName: node
13711-
linkType: hard
13712-
1371313719
"data-urls@npm:^2.0.0":
1371413720
version: 2.0.0
1371513721
resolution: "data-urls@npm:2.0.0"
@@ -15937,16 +15943,6 @@ __metadata:
1593715943
languageName: node
1593815944
linkType: hard
1593915945

15940-
"fetch-blob@npm:^3.1.2, fetch-blob@npm:^3.1.4":
15941-
version: 3.2.0
15942-
resolution: "fetch-blob@npm:3.2.0"
15943-
dependencies:
15944-
node-domexception: ^1.0.0
15945-
web-streams-polyfill: ^3.0.3
15946-
checksum: f19bc28a2a0b9626e69fd7cf3a05798706db7f6c7548da657cbf5026a570945f5eeaedff52007ea35c8bcd3d237c58a20bf1543bc568ab2422411d762dd3d5bf
15947-
languageName: node
15948-
linkType: hard
15949-
1595015946
"fflate@npm:^0.7.4":
1595115947
version: 0.7.4
1595215948
resolution: "fflate@npm:0.7.4"
@@ -16276,15 +16272,6 @@ __metadata:
1627616272
languageName: node
1627716273
linkType: hard
1627816274

16279-
"formdata-polyfill@npm:^4.0.10":
16280-
version: 4.0.10
16281-
resolution: "formdata-polyfill@npm:4.0.10"
16282-
dependencies:
16283-
fetch-blob: ^3.1.2
16284-
checksum: 82a34df292afadd82b43d4a740ce387bc08541e0a534358425193017bf9fb3567875dc5f69564984b1da979979b70703aa73dee715a17b6c229752ae736dd9db
16285-
languageName: node
16286-
linkType: hard
16287-
1628816275
"formik@npm:^2.1.5":
1628916276
version: 2.2.9
1629016277
resolution: "formik@npm:2.2.9"
@@ -21940,13 +21927,6 @@ __metadata:
2194021927
languageName: node
2194121928
linkType: hard
2194221929

21943-
"node-domexception@npm:^1.0.0":
21944-
version: 1.0.0
21945-
resolution: "node-domexception@npm:1.0.0"
21946-
checksum: ee1d37dd2a4eb26a8a92cd6b64dfc29caec72bff5e1ed9aba80c294f57a31ba4895a60fd48347cf17dd6e766da0ae87d75657dfd1f384ebfa60462c2283f5c7f
21947-
languageName: node
21948-
linkType: hard
21949-
2195021930
"node-emoji@npm:^1.10.0":
2195121931
version: 1.10.0
2195221932
resolution: "node-emoji@npm:1.10.0"
@@ -22012,14 +21992,17 @@ __metadata:
2201221992
languageName: node
2201321993
linkType: hard
2201421994

22015-
"node-fetch@npm:^3.3.2":
22016-
version: 3.3.2
22017-
resolution: "node-fetch@npm:3.3.2"
21995+
"node-fetch@npm:^2.7.0":
21996+
version: 2.7.0
21997+
resolution: "node-fetch@npm:2.7.0"
2201821998
dependencies:
22019-
data-uri-to-buffer: ^4.0.0
22020-
fetch-blob: ^3.1.4
22021-
formdata-polyfill: ^4.0.10
22022-
checksum: 06a04095a2ddf05b0830a0d5302699704d59bda3102894ea64c7b9d4c865ecdff2d90fd042df7f5bc40337266961cb6183dcc808ea4f3000d024f422b462da92
21999+
whatwg-url: ^5.0.0
22000+
peerDependencies:
22001+
encoding: ^0.1.0
22002+
peerDependenciesMeta:
22003+
encoding:
22004+
optional: true
22005+
checksum: d76d2f5edb451a3f05b15115ec89fc6be39de37c6089f1b6368df03b91e1633fd379a7e01b7ab05089a25034b2023d959b47e59759cb38d88341b2459e89d6e5
2202322006
languageName: node
2202422007
linkType: hard
2202522008

@@ -30284,13 +30267,6 @@ __metadata:
3028430267
languageName: node
3028530268
linkType: hard
3028630269

30287-
"web-streams-polyfill@npm:^3.0.3":
30288-
version: 3.3.2
30289-
resolution: "web-streams-polyfill@npm:3.3.2"
30290-
checksum: 0292f4113c1bda40d8e8ecebee39eb14cc2e2e560a65a6867980e394537a2645130e2c73f5ef6e641fd3697d2f71720ccf659aebaf69a9d5a773f653a0fdf39d
30291-
languageName: node
30292-
linkType: hard
30293-
3029430270
"webidl-conversions@npm:^3.0.0":
3029530271
version: 3.0.1
3029630272
resolution: "webidl-conversions@npm:3.0.1"

0 commit comments

Comments
 (0)