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

fix: rename react directory to reactjs #2884

Merged
merged 5 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/src/pages/guides/migrating-to-react-query-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,20 @@ For the same reason, those have also been combined:
```

This flag defaults to `active` because `refetchActive` defaulted to `true`. This means we also need a way to tell `invalidateQueries` to not refetch at all, which is why a fourth option (`none`) is also allowed here.

### The `src/react` directory was renamed to `src/reactjs`

Previously, react-query had a directory named `react` which imported from the `react` module. This could cause problems with some Jest configurations, resulting in errors when running tests like:

```
TypeError: Cannot read property 'createContext' of undefined
```

With the renamed directory this no longer is an issue.

If you were importing anything from `'react-query/react'` directly in your project (as opposed to just `'react-query'`), then you need to update your imports:

```diff
- import { QueryClientProvider } from 'react-query/react';
+ import { QueryClientProvider } from 'react-query/reactjs';
```
20 changes: 12 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"module": "es/index.js",
"sideEffects": [
"es/index.js",
"es/react/index.js",
"es/react/setBatchUpdatesFn.js",
"es/react/setLogger.js",
"es/reactjs/index.js",
"es/reactjs/setBatchUpdatesFn.js",
"es/reactjs/setLogger.js",
"lib/index.js",
"lib/react/index.js",
"lib/react/setBatchUpdatesFn.js",
"lib/react/setLogger.js"
"lib/reactjs/index.js",
"lib/reactjs/setBatchUpdatesFn.js",
"lib/reactjs/setLogger.js"
],
"scripts": {
"test": "is-ci \"test:ci\" \"test:dev\"",
Expand Down Expand Up @@ -60,7 +60,7 @@
"createAsyncStoragePersistor-experimental",
"broadcastQueryClient-experimental",
"lib",
"react",
"reactjs",
"scripts",
"types"
],
Expand All @@ -81,7 +81,11 @@
}
},
"typesVersions": {
"<4.1": { "types/*": ["types/ts3.8/*"] }
"<4.1": {
"types/*": [
"types/ts3.8/*"
]
}
},
"devDependencies": {
"@babel/cli": "^7.11.6",
Expand Down
6 changes: 0 additions & 6 deletions react/package.json

This file was deleted.

6 changes: 6 additions & 0 deletions reactjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"internal": true,
"main": "../lib/reactjs/index.js",
"module": "../es/reactjs/index.js",
"types": "../types/reactjs/index.d.ts"
}
2 changes: 1 addition & 1 deletion src/core/tests/hydration.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mockNavigatorOnLine, sleep } from '../../react/tests/utils'
import { mockNavigatorOnLine, sleep } from '../../reactjs/tests/utils'
import { QueryCache } from '../queryCache'
import { QueryClient } from '../queryClient'
import { dehydrate, hydrate } from '../hydration'
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/infiniteQueryBehavior.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { waitFor } from '@testing-library/react'
import { queryKey, mockConsoleError } from '../../react/tests/utils'
import { queryKey, mockConsoleError } from '../../reactjs/tests/utils'
import {
QueryClient,
InfiniteQueryObserver,
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/infiniteQueryObserver.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sleep, queryKey } from '../../react/tests/utils'
import { sleep, queryKey } from '../../reactjs/tests/utils'
import { QueryClient, InfiniteQueryObserver } from '../..'

describe('InfiniteQueryObserver', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/mutationCache.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { queryKey, mockConsoleError } from '../../react/tests/utils'
import { queryKey, mockConsoleError } from '../../reactjs/tests/utils'
import { MutationCache, QueryClient } from '../..'

describe('mutationCache', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/mutationObserver.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { waitFor } from '@testing-library/react'
import { sleep } from '../../react/tests/utils'
import { sleep } from '../../reactjs/tests/utils'
import { QueryClient, MutationObserver } from '../..'

describe('mutationObserver', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/mutations.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryClient } from '../..'
import { mockConsoleError, queryKey, sleep } from '../../react/tests/utils'
import { mockConsoleError, queryKey, sleep } from '../../reactjs/tests/utils'
import { MutationState } from '../mutation'
import { MutationObserver } from '../mutationObserver'

Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/queriesObserver.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { waitFor } from '@testing-library/react'
import { sleep, queryKey } from '../../react/tests/utils'
import { sleep, queryKey } from '../../reactjs/tests/utils'
import {
QueryClient,
QueriesObserver,
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
queryKey,
mockVisibilityState,
mockConsoleError,
} from '../../react/tests/utils'
} from '../../reactjs/tests/utils'
import {
QueryCache,
QueryClient,
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/queryCache.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sleep, queryKey, mockConsoleError } from '../../react/tests/utils'
import { sleep, queryKey, mockConsoleError } from '../../reactjs/tests/utils'
import { QueryCache, QueryClient } from '../..'
import { Query } from '.././query'

Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/queryClient.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sleep, queryKey, mockConsoleError } from '../../react/tests/utils'
import { sleep, queryKey, mockConsoleError } from '../../reactjs/tests/utils'
import {
InfiniteQueryObserver,
QueryCache,
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/queryObserver.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
queryKey,
mockConsoleError,
expectType,
} from '../../react/tests/utils'
} from '../../reactjs/tests/utils'
import {
QueryClient,
QueryObserver,
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
scheduleMicrotask,
} from '../utils'
import { QueryClient, QueryCache, setLogger, Logger } from '../..'
import { queryKey } from '../../react/tests/utils'
import { queryKey } from '../../reactjs/tests/utils'
import { Mutation } from '../mutation'
import { waitFor } from '@testing-library/dom'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dehydrate, MutationCache, QueryCache, QueryClient } from '../../core'
import { sleep } from '../../react/tests/utils'
import { sleep } from '../../reactjs/tests/utils'
import { createWebStoragePersistor } from '../index'

function getMockStorage(limitSize?: number) {
Expand Down
15 changes: 15 additions & 0 deletions src/hydration/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This package once contained these functions, but they have now been moved
// into the core and react packages.
// They are re-exported here to avoid a breaking change, but this package
// should be considered deprecated and removed in a future major version.
export { dehydrate, hydrate, useHydrate, Hydrate } from 'react-query'

// Types
export type {
DehydrateOptions,
DehydratedState,
HydrateOptions,
ShouldDehydrateMutationFunction,
ShouldDehydrateQueryFunction,
} from '../core/hydration'
export type { HydrateProps } from '../reactjs/Hydrate'
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './core'
export * from './react'
export * from './reactjs'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ts3.8/useQueries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UseQueryOptions, UseQueryResult } from '../react/types'
import { UseQueryOptions, UseQueryResult } from '../reactjs/types'

/**
* Backwards-compatible definition for TS < 4.1
Expand Down