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

rebranded imports #3803

Merged
merged 23 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
12bdcaf
refactor: apply import codemod to examples
TkDodo Jul 13, 2022
850d6ac
refactor: update import in typescript example
TkDodo Jul 13, 2022
7b590f7
refactor: more import updates
TkDodo Jul 13, 2022
074b166
Merge remote-tracking branch 'tannerlinsley/beta' into feature/rebran…
TkDodo Jul 13, 2022
279dcc7
chore: run prettier over examples
TkDodo Jul 13, 2022
bd3a475
chore: try to setup codesandbox-ci for the monorepo structure
TkDodo Jul 13, 2022
eb6492c
chore: force the use of npm ci in the pipeline
TkDodo Jul 13, 2022
5bcd21a
chore: install with leagacy peer deps
TkDodo Jul 13, 2022
cb2cf47
chore: try --force instead
TkDodo Jul 13, 2022
7e73283
chore: re-generate lock file in the hopes that it fixes the install p…
TkDodo Jul 13, 2022
4bb26c6
chore: force testing-library to v12.1.4
TkDodo Jul 13, 2022
5b5c2da
chore: try again with legacy peer deps now that only eslint-config is…
TkDodo Jul 13, 2022
c4be184
chore: try if removing examples from workspaces changes a damn thing
TkDodo Jul 13, 2022
055add9
Revert "chore: try if removing examples from workspaces changes a dam…
TkDodo Jul 13, 2022
c8945b8
chore: try a specific node version
TkDodo Jul 13, 2022
09b506a
chore: add dependencies to correct packages
TkDodo Jul 13, 2022
d451c80
chore: add missing dev dependencies (maybe)
TkDodo Jul 13, 2022
5a58261
chore: add more top level devDependencies
TkDodo Jul 13, 2022
97b149f
chore: move jscodeshift to the top, too
TkDodo Jul 13, 2022
fe873f0
chore: try with npm install
TkDodo Jul 13, 2022
172825e
chore: run node16 only!
TkDodo Jul 13, 2022
b81f091
chore: run node16 only
TkDodo Jul 13, 2022
03b0430
chore: remove devDependencies from top level package.json again
TkDodo Jul 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"installCommand": "install:csb",
"sandboxes": ["/examples/react/basic", "/examples/react/basic-typescript"],
"packages": ["packages/**"],
"node": "16"
}
6 changes: 4 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16]
node: [16.14.2]
react: [17, 18]
steps:
- uses: actions/checkout@v2
Expand All @@ -15,11 +15,13 @@ jobs:
node-version: ${{ matrix.node }}
- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
install-command: npm install
- run: npm run test:ci
env:
REACTJS_VERSION: ${{ matrix.react }}
- run: npm run test:size
if: matrix.node == '16' && matrix.react == '18'
if: matrix.react == '18'
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
- name: Upload coverage to Codecov
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
v16.14.2
4 changes: 2 additions & 2 deletions docs/plugins/createAsyncStoragePersister.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ This utility comes packaged with `react-query` and is available under the `react

```ts
import AsyncStorage from '@react-native-async-storage/async-storage'
import { persistQueryClient } from 'react-query/persistQueryClient'
import { createAsyncStoragePersister } from 'react-query/createAsyncStoragePersister'
import { persistQueryClient } from '@tanstack/react-query-persist-client'
import { createSyncStoragePersister } from '@tanstack/query-async-storage-persister'

const queryClient = new QueryClient({
defaultOptions: {
Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/createSyncStoragePersister.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export type PersistRetryer = (props: {

### Predefined strategies

Per default, no retry will occur. You can use one of the predefined strategies to handle retries. They can be imported `from 'react-query/persistQueryClient'`:
Per default, no retry will occur. You can use one of the predefined strategies to handle retries. They can be imported `from '@tanstack/react-query-persist-client'`:

- `removeOldestQuery`
- will return a new `PersistedClient` with the oldest query removed.
Expand Down
4 changes: 2 additions & 2 deletions docs/plugins/persistQueryClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ export interface PersistedClient {

You can import these (to build a persister):
```ts
import { PersistedClient, Persister } from "react-query/persistQueryClient";
import { PersistedClient, Persister } from "@tanstack/react-query-persist-client";
```

### Building A Persister
You can persist however you like. Here is an example of how to build an [Indexed DB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) persister. Compared to `Web Storage API`, Indexed DB is faster, stores more than 5MB, and doesn't require serialization. That means it can readily store Javascript native types, such as `Date` and `File`.

```ts
import { get, set, del } from "idb-keyval";
import { PersistedClient, Persister } from "react-query/persistQueryClient";
import { PersistedClient, Persister } from "@tanstack/react-query-persist-client";

/**
* Creates an Indexed DB persister
Expand Down
4 changes: 2 additions & 2 deletions examples/react/auto-refetching/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
useMutation,
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
} from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"

const queryClient = new QueryClient()

Expand Down
4 changes: 2 additions & 2 deletions examples/react/basic-graphql-request/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
useQueryClient,
QueryClient,
QueryClientProvider,
} from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
} from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { request, gql } from "graphql-request";

const endpoint = "https://graphqlzero.almansi.me/api";
Expand Down
25 changes: 11 additions & 14 deletions examples/react/basic-typescript/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import * as React from "react";
import ReactDOM from "react-dom/client";
import axios from "axios";
import { useQuery, useQueryClient, QueryClient } from "react-query";
import { PersistQueryClientProvider } from "react-query/persistQueryClient";
import { createWebStoragePersister } from "react-query/createWebStoragePersister";
import { ReactQueryDevtools } from "react-query/devtools";
import { useQuery, useQueryClient, QueryClient } from "@tanstack/react-query";
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";
import { createSyncStoragePersister } from "@tanstack/query-sync-storage-persister";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

const queryClient = new QueryClient({
defaultOptions: {
Expand All @@ -15,7 +15,7 @@ const queryClient = new QueryClient({
},
});

const persister = createWebStoragePersister({
const persister = createSyncStoragePersister({
storage: window.localStorage,
});

Expand All @@ -26,15 +26,12 @@ type Post = {
};

function usePosts() {
return useQuery(
["posts"],
async (): Promise<Array<Post>> => {
const { data } = await axios.get(
"https://jsonplaceholder.typicode.com/posts"
);
return data;
}
);
return useQuery(["posts"], async (): Promise<Array<Post>> => {
const { data } = await axios.get(
"https://jsonplaceholder.typicode.com/posts"
);
return data;
});
}

function Posts({
Expand Down
4 changes: 2 additions & 2 deletions examples/react/basic/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
useQueryClient,
QueryClient,
QueryClientProvider,
} from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
} from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

const queryClient = new QueryClient();

Expand Down
2 changes: 1 addition & 1 deletion examples/react/custom-hooks/src/hooks/usePost.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import axios from "axios";

const getPostById = async (postId) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/custom-hooks/src/hooks/usePosts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import axios from "axios";

const getPosts = async () => {
Expand Down
4 changes: 2 additions & 2 deletions examples/react/custom-hooks/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from "react";
import ReactDOM from "react-dom/client";
import { QueryClient, QueryClientProvider, useQueryClient } from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
import { QueryClient, QueryClientProvider, useQueryClient } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

import usePosts from "./hooks/usePosts";
import usePost from "./hooks/usePost";
Expand Down
4 changes: 2 additions & 2 deletions examples/react/default-query-function/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
useQueryClient,
QueryClient,
QueryClientProvider,
} from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
} from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

// Define a default query function that will receive the query key
const defaultQueryFn = async ({ queryKey }) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/react/focus-refetching/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
useMutation,
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
} from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"

const queryClient = new QueryClient()

Expand Down
4 changes: 2 additions & 2 deletions examples/react/load-more-infinite-scroll/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
useInfiniteQuery,
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
} from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"

const queryClient = new QueryClient()

Expand Down
4 changes: 2 additions & 2 deletions examples/react/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"ky": "^0.23.0",
"ky-universal": "^0.8.2",
"next": "latest",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-query": "^4.0.0-beta.1",
"resolve-from": "^5.0.0",
"web-streams-polyfill": "^3.0.3"
Expand Down
2 changes: 1 addition & 1 deletion examples/react/nextjs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'

export default function MyApp({ Component, pageProps }) {
const [queryClient] = React.useState(() => new QueryClient())
Expand Down
4 changes: 2 additions & 2 deletions examples/react/offline/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
MutationCache,
onlineManager,
useIsRestoring,
} from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
} from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import toast, { Toaster } from "react-hot-toast";

import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";
Expand Down
6 changes: 1 addition & 5 deletions examples/react/offline/src/movies.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import {
MutationCache,
QueryClient,
useMutation,
useQuery,
useQueryClient,
} from "react-query";
import toast from "react-hot-toast";
} from "@tanstack/react-query";
import * as api from "./api";
import * as React from "react";
import { useMatch } from "@tanstack/react-location";

export const movieKeys = {
all: () => ["movies"],
Expand Down
5 changes: 2 additions & 3 deletions examples/react/optimistic-updates-typescript/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import * as React from 'react'
import axios, { AxiosError } from 'axios'
import axios from 'axios'

import {
useQuery,
useQueryClient,
useMutation,
QueryClient,
QueryClientProvider,
UseQueryOptions,
} from '@tanstack/react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'

const client = new QueryClient()

Expand Down
4 changes: 2 additions & 2 deletions examples/react/optimistic-updates/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
useMutation,
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
} from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"

const queryClient = new QueryClient()

Expand Down
4 changes: 2 additions & 2 deletions examples/react/pagination/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
useQueryClient,
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
} from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"

const queryClient = new QueryClient()

Expand Down
4 changes: 2 additions & 2 deletions examples/react/playground/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
useQuery,
useQueryClient,
useMutation,
} from "react-query";
} from "@tanstack/react-query";

import { ReactQueryDevtools } from "react-query/devtools";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

import "./styles.css";

Expand Down
4 changes: 2 additions & 2 deletions examples/react/prefetching/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
useQueryClient,
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
} from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"

const getCharacters = async () => {
await new Promise((r) => setTimeout(r, 500))
Expand Down
4 changes: 2 additions & 2 deletions examples/react/rick-morty/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { BrowserRouter as Router } from "react-router-dom";
import { ThemeProvider } from "@material-ui/core";
import { createMuiTheme } from "@material-ui/core/styles";

import { QueryClient, QueryClientProvider } from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

import "./styles.css";
import Layout from "./Layout";
Expand Down
2 changes: 1 addition & 1 deletion examples/react/rick-morty/src/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "@material-ui/core";
import { Link as RouterLink } from "react-router-dom";
import { useParams } from "react-router";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import fetch from "./fetch";

function Character() {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/rick-morty/src/Characters.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Typography, Link } from "@material-ui/core";
import { Link as RouterLink } from "react-router-dom";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import fetch from "./fetch";

export default function Characters() {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/rick-morty/src/Episode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { Typography, Link } from "@material-ui/core";
import { Link as RouterLink } from "react-router-dom";
import { useParams } from "react-router";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import fetch from "./fetch";

function Episode() {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/rick-morty/src/Episodes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Typography, Link } from "@material-ui/core";
import { Link as RouterLink } from "react-router-dom";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import fetch from "./fetch";

export default function Episodes() {
Expand Down
4 changes: 2 additions & 2 deletions examples/react/simple/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from "react";
import ReactDOM from "react-dom/client";
import { QueryClient, QueryClientProvider, useQuery } from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import axios from "axios";

const queryClient = new QueryClient();
Expand Down
4 changes: 2 additions & 2 deletions examples/react/star-wars/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { BrowserRouter as Router } from "react-router-dom";
import { ThemeProvider } from "@material-ui/core";
import { createMuiTheme } from "@material-ui/core/styles";

import { QueryClient, QueryClientProvider } from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

import "./styles.css";
import Layout from "./Layout";
Expand Down
2 changes: 1 addition & 1 deletion examples/react/star-wars/src/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "@material-ui/core";
import { Link as RouterLink } from "react-router-dom";
import { withRouter } from "react-router";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import fetch from "./fetch";

function Character(props) {
Expand Down
Loading