Skip to content

Commit 868eee6

Browse files
committed
Merge branch 'master' into feature/2149
# Conflicts: # src/core/types.ts
2 parents d70abce + 94986b4 commit 868eee6

File tree

21 files changed

+201
-95
lines changed

21 files changed

+201
-95
lines changed

.github/workflows/test-and-publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
node: [10, 12, 14]
19+
node: [10, 12, 14, 16]
2020
steps:
2121
- uses: actions/checkout@v2
22-
- uses: actions/setup-node@v1
22+
- uses: actions/setup-node@v2
2323
with:
2424
node-version: ${{ matrix.node }}
2525
- name: Install dependencies
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ubuntu-latest
3535
steps:
3636
- uses: actions/checkout@v2
37-
- uses: actions/setup-node@v1
37+
- uses: actions/setup-node@v2
3838
with:
3939
node-version: 14
4040
registry-url: https://registry.npmjs.org/

docs/src/pages/guides/filters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ A query filter is an object with certain conditions to match a query with:
1313
// Cancel all queries
1414
await queryClient.cancelQueries()
1515

16-
// Remove all inactive queries
16+
// Remove all inactive queries that begin with `posts` in the key
1717
queryClient.removeQueries('posts', { inactive: true })
1818

1919
// Refetch all active queries
2020
await queryClient.refetchQueries({ active: true })
2121

22-
// Refetch all active queries that begin with `post` in the key
22+
// Refetch all active queries that begin with `posts` in the key
2323
await queryClient.refetchQueries('posts', { active: true })
2424
```
2525

docs/src/pages/guides/mutations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ A mutation can only be in one of the following states at any given moment:
4444
- `isError` or `status === 'error'` - The mutation encountered an error
4545
- `isSuccess` or `status === 'success'` - The mutation was successful and mutation data is available
4646

47-
Beyond those primary state, more information is available depending on the state the mutation:
47+
Beyond those primary states, more information is available depending on the state of the mutation:
4848

4949
- `error` - If the mutation is in an `isError` state, the error is available via the `error` property.
5050
- `data` - If the mutation is in a `success` state, the data is available via the `data` property.

docs/src/pages/guides/placeholder-query-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ In some circumstances, you may be able to provide the placeholder data for a que
4343

4444
```js
4545
function Todo({ blogPostId }) {
46-
const result = useQuery(['blogPost', blogPostId], () => fetch('/blogPosts'), {
46+
const result = useQuery(['blogPost', blogPostId], () => fetch(`/blogPosts/${blogPostId}`), {
4747
placeholderData: () => {
4848
// Use the smaller/preview version of the blogPost from the 'blogPosts' query as the placeholder data for this blogPost query
4949
return queryClient

docs/src/pages/guides/updates-from-mutation-responses.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ When dealing with mutations that **update** objects on the server, it's common f
99
const queryClient = useQueryClient()
1010

1111
const mutation = useMutation(editTodo, {
12-
onSuccess: data => queryClient.setQueryData(['todo', { id: 5 }], data),
12+
onSuccess: data => {
13+
queryClient.setQueryData(['todo', { id: 5 }], data)
14+
}
1315
})
1416

1517
mutation.mutate({

docs/src/pages/plugins/persistQueryClient.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ interface PersistQueryClientOptions {
9494
/** A unique string that can be used to forcefully
9595
* invalidate existing caches if they do not share the same buster string */
9696
buster?: string
97+
/** The options passed to the hydrate function */
98+
hydrateOptions?: HydrateOptions
99+
/** The options passed to the dehydrate function */
100+
dehydrateOptions?: DehydrateOptions
97101
}
98102
```
99103

docs/src/pages/reference/useMutation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ mutate(variables, {
4646
- This function will fire before the mutation function is fired and is passed the same variables the mutation function would receive
4747
- Useful to perform optimistic updates to a resource in hopes that the mutation succeeds
4848
- The value returned from this function will be passed to both the `onError` and `onSettled` functions in the event of a mutation failure and can be useful for rolling back optimistic updates.
49-
- `onSuccess: (data: TData, variables: TVariables, context?: TContext) => Promise<void> | void`
49+
- `onSuccess: (data: TData, variables: TVariables, context?: TContext) => Promise<unknown> | void`
5050
- Optional
5151
- This function will fire when the mutation is successful and will be passed the mutation's result.
5252
- If a promise is returned, it will be awaited and resolved before proceeding
53-
- `onError: (err: TError, variables: TVariables, context?: TContext) => Promise<void> | void`
53+
- `onError: (err: TError, variables: TVariables, context?: TContext) => Promise<unknown> | void`
5454
- Optional
5555
- This function will fire if the mutation encounters an error and will be passed the error.
5656
- If a promise is returned, it will be awaited and resolved before proceeding
57-
- `onSettled: (data: TData, error: TError, variables: TVariables, context?: TContext) => Promise<void> | void`
57+
- `onSettled: (data: TData, error: TError, variables: TVariables, context?: TContext) => Promise<unknown> | void`
5858
- Optional
5959
- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
6060
- If a promise is returned, it will be awaited and resolved before proceeding

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
],
2323
"scripts": {
2424
"test": "is-ci \"test:ci\" \"test:dev\"",
25-
"test:dev": "npm run test:types && npm run test:eslint && jest --watch",
26-
"test:ci": "npm run test:types && npm run test:eslint && jest",
25+
"test:dev": "npm run test:types && npm run test:format && npm run test:eslint && jest --watch",
26+
"test:ci": "npm run test:types && npm run test:format && npm run test:eslint && jest",
2727
"test:coverage": "yarn test:ci; open coverage/lcov-report/index.html",
28+
"test:format": "yarn prettier --check",
2829
"test:types": "tsc",
2930
"test:eslint": "eslint --ext .ts,.tsx ./src",
3031
"build": "yarn build:commonjs && yarn build:es && yarn build:umd && yarn build:types",
@@ -38,8 +39,9 @@
3839
"watch:umd": "rimraf ./dist && cross-env NODE_ENV=production rollup -w -c && rollup-plugin-visualizer stats-react.json",
3940
"watch:types": "rimraf ./types && tsc --watch --project ./tsconfig.types.json && replace 'import type' 'import' ./types -r --silent && replace 'export type' 'export' ./types -r --silent",
4041
"now-build": "yarn && cd www && yarn && yarn build",
42+
"prettier": "prettier \"{.,src,src/**,example/src,example/src/**,types}/*.{md,js,jsx,ts,tsx,json}\"",
4143
"start": "yarn watch",
42-
"format": "prettier {.,src,src/**,example/src,example/src/**,types}/*.{md,js,jsx,tsx,json} --write",
44+
"format": "yarn prettier --write",
4345
"stats": "open ./stats.html"
4446
},
4547
"files": [
@@ -108,7 +110,7 @@
108110
"eslint-plugin-standard": "^4.0.1",
109111
"is-ci-cli": "^2.1.1",
110112
"jest": "^26.0.1",
111-
"prettier": "^2.0.5",
113+
"prettier": "2.2.1",
112114
"react": "^16.13.0",
113115
"react-dom": "^16.13.1",
114116
"react-error-boundary": "^2.2.2",

src/core/focusManager.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class FocusManager extends Subscribable {
1212
}
1313

1414
setEventListener(
15-
setup: (onFocus: () => void) => (focused?: boolean) => void
15+
setup: (setFocused: (focused?: boolean) => void) => () => void
1616
): void {
1717
if (this.removeEventListener) {
1818
this.removeEventListener()
1919
}
20-
this.removeEventListener = setup((focused?: boolean) => {
20+
this.removeEventListener = setup(focused => {
2121
if (typeof focused === 'boolean') {
2222
this.setFocused(focused)
2323
} else {
@@ -58,14 +58,15 @@ class FocusManager extends Subscribable {
5858
private setDefaultEventListener() {
5959
if (!isServer && window?.addEventListener) {
6060
this.setEventListener(onFocus => {
61+
const listener = () => onFocus()
6162
// Listen to visibillitychange and focus
62-
window.addEventListener('visibilitychange', onFocus, false)
63-
window.addEventListener('focus', onFocus, false)
63+
window.addEventListener('visibilitychange', listener, false)
64+
window.addEventListener('focus', listener, false)
6465

6566
return () => {
6667
// Be sure to unsubscribe if a new handler is set
67-
window.removeEventListener('visibilitychange', onFocus)
68-
window.removeEventListener('focus', onFocus)
68+
window.removeEventListener('visibilitychange', listener)
69+
window.removeEventListener('focus', listener)
6970
}
7071
})
7172
}

src/core/mutationCache.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ export class MutationCache extends Subscribable<MutationCacheListener> {
7676
return this.mutations
7777
}
7878

79-
find<
80-
TData = unknown,
81-
TError = unknown,
82-
TVariables = any,
83-
TContext = unknown
84-
>(
79+
find<TData = unknown, TError = unknown, TVariables = any, TContext = unknown>(
8580
filters: MutationFilters
8681
): Mutation<TData, TError, TVariables, TContext> | undefined {
8782
if (typeof filters.exact === 'undefined') {

0 commit comments

Comments
 (0)