Skip to content

fix: react native uSES #4185

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

Merged
merged 1 commit into from
Sep 19, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/react-query/src/useSyncExternalStore.native.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
// @ts-ignore
export { useSyncExternalStore } from 'use-sync-external-store/shim/index.native.js'
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.native.js'

export { useSyncExternalStore }
4 changes: 3 additions & 1 deletion packages/react-query/src/useSyncExternalStore.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
export { useSyncExternalStore } from 'use-sync-external-store/shim/index.js'
import { useSyncExternalStore as uSES } from 'use-sync-external-store/shim/index.js'

export const useSyncExternalStore = uSES
4 changes: 3 additions & 1 deletion rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ export default function rollup(options: RollupOptions): RollupOptions[] {
packageDir: 'packages/react-query',
jsName: 'ReactQuery',
outputFile: 'index',
entryFile: ['src/index.ts', 'src/reactBatchedUpdates.native.ts'],
entryFile: ['src/index.ts', 'src/reactBatchedUpdates.native.ts', 'src/useSyncExternalStore.native.ts'],
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'@tanstack/query-core': 'QueryCore',
'use-sync-external-store/shim/index.js': 'UseSyncExternalStore',
'use-sync-external-store/shim/index.native.js': 'UseSyncExternalStoreNative',
'react-native': 'ReactNative',
},
bundleUMDGlobals: [
Expand Down Expand Up @@ -321,6 +322,7 @@ function cjs({
// TODO: figure out a better way to produce extensionless cjs imports
"require('./logger.js')": "require('./logger')",
"require('./reactBatchedUpdates.js')": "require('./reactBatchedUpdates')",
"require('./useSyncExternalStore.js')": "require('./useSyncExternalStore')",
preventAssignment: true,
delimiters: ['', ''],
}),
Expand Down