If window is undefined, we'd skip initialization of the event,
but window.removeEventListener would still be attempted
to be called upon cleanup and fail with error due to undefined
window.
* refactor(query-core): export isPlainObject
* refactor(useBaseQuery): dev error in case of bad argument
Mainly for project without TS. This helps tracking bad signature when migrating from v4 to v5.
* refactor(useQueryClient): dev error in case of bad queryClient
Mainly for project without TS. Make sure the queryClient passed as parameter is really a query. With the change of signature introduced by v5, queryOptions from useQuery could end up as queryClient due to how useBaseQuery works.
* revert: "refactor(useQueryClient): dev error in case of bad queryClient"
This reverts commit 9bedf21782.
* refactor(useQuery): manual test to avoid export from query-core.
* refactor(useQuery test): TS ignore invalid call
---------
Co-authored-by: Guillaume Labat <guillaume.labat+git@imagino.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* chore(codemod): add named examples to the `keep-previous-data` codemod, because these were missing
* chore(codemod): remove the unnecessary `return` statement
* feat(codemod): cover the `setQueryDefaults` method usages on the `QueryClient` instance with the codemod
For further details see: https://github.com/TanStack/query/pull/6196#discussion_r1377371519
* chore(codemod): rename the `isKeepPreviousDataInUse` to `shouldAddKeepPreviousDataImport`
The new name describes better the purpose of this variable.
* feat(codemod): cover the `QueryClient` class instantiations with the codemod
For further details see: https://github.com/TanStack/query/pull/6196#discussion_r1377371519
* chore(codemod): fix `eslint` issues within the `keep-previous-data` codemod
* chore(codemod): fix the `prettier` issues within the `keep-previous-data` codemod README file
* chore(codemod): turn off the `sort-imports` ESLint rule in case of the codemods
Since the codemods might not respect the import order, it's easier to turn off the `sort-imports` ESLint rule.
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
It's necessary, because before this change the above-mentioned function was looking for imports from the `react-query` package, but the package was renamed in the version 4 release. In case of the older codemods the `react-query` is still a valid package name, but for the current and future codemods we have to locate imports from the `@tanstack/react-query` package.
- I noticed this while I was trying to use useQuery and trying to capture the error property.
I think this is something which can be added as extra information for those who will be using it for first time.
* Simplify load method, fix syntax highlighting
SvelteKit now automatically infers the type of an exported load method, so no need to manually define it.
Also, Github has an ongoing issue with the Svelte syntax highlighting so using `html` is a good fallback.
* Change back to using svelte for code blocks
---------
Co-authored-by: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com>
* feat(codemod): add initial implementation of the `placeholderData` codemod
* chore(codemod): remove the parameter from the `placeholderData` function examples
It was a request by @TkDodo, since in `v4` the `placeholderData` function didn't have a parameter.
For further details see: https://github.com/TanStack/query/pull/6196#discussion_r1366618334
* chore(codemod): add an example where the `placeholderData` property is not a function
It was a request by @TkDodo, see: https://github.com/TanStack/query/pull/6196#discussion_r1366618334
* refactor(codemod): transform the usage only when the `keepPreviousData` has value `true`
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
To ensure comprehensive documentation, I have included the import declaration to ensure that everyone is aware that the import is necessary for the module augmentation to function properly.
If you omit the import, you will overwrite the entire react-query declaration.