react-saga-redux 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +63 -0
- package/dist/index.d.mts +569 -0
- package/dist/index.d.ts +569 -0
- package/dist/index.js +1188 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1138 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +100 -0
- package/src/components/Context.ts +50 -0
- package/src/components/Props.ts +111 -0
- package/src/components/Provider.tsx +105 -0
- package/src/components/connect.tsx +813 -0
- package/src/connect/invalidArgFactory.ts +14 -0
- package/src/connect/mapDispatchToProps.ts +25 -0
- package/src/connect/mapProps.ts +43 -0
- package/src/connect/mapStateToProps.ts +14 -0
- package/src/connect/mergeProps.ts +78 -0
- package/src/connect/selectorFactory.ts +242 -0
- package/src/connect/verifySubselectors.ts +26 -0
- package/src/connect/wrapMapToProps.ts +110 -0
- package/src/exports.ts +54 -0
- package/src/hooks/useDispatch.ts +104 -0
- package/src/hooks/useReduxContext.ts +42 -0
- package/src/hooks/useSelector.ts +286 -0
- package/src/hooks/useStore.ts +123 -0
- package/src/index-rsc.ts +34 -0
- package/src/index.ts +1 -0
- package/src/types.ts +180 -0
- package/src/utils/Subscription.ts +183 -0
- package/src/utils/batch.ts +4 -0
- package/src/utils/bindActionCreators.ts +16 -0
- package/src/utils/constants.ts +23 -0
- package/src/utils/hoistStatics.ts +139 -0
- package/src/utils/isPlainObject.ts +17 -0
- package/src/utils/react-is.ts +97 -0
- package/src/utils/react.ts +3 -0
- package/src/utils/shallowEqual.ts +36 -0
- package/src/utils/useIsomorphicLayoutEffect.ts +40 -0
- package/src/utils/useSyncExternalStore.ts +9 -0
- package/src/utils/verifyPlainObject.ts +14 -0
- package/src/utils/warning.ts +21 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { React } from '../utils/react'
|
|
2
|
+
|
|
3
|
+
// React currently throws a warning when using useLayoutEffect on the server.
|
|
4
|
+
// To get around it, we can conditionally useEffect on the server (no-op) and
|
|
5
|
+
// useLayoutEffect in the browser. We need useLayoutEffect to ensure the store
|
|
6
|
+
// subscription callback always has the selector from the latest render commit
|
|
7
|
+
// available, otherwise a store update may happen between render and the effect,
|
|
8
|
+
// which may cause missed updates; we also must ensure the store subscription
|
|
9
|
+
// is created synchronously, otherwise a store update may occur before the
|
|
10
|
+
// subscription is created and an inconsistent state may be observed
|
|
11
|
+
|
|
12
|
+
// Matches logic in React's `shared/ExecutionEnvironment` file
|
|
13
|
+
const canUseDOM = () =>
|
|
14
|
+
!!(
|
|
15
|
+
typeof window !== 'undefined' &&
|
|
16
|
+
typeof window.document !== 'undefined' &&
|
|
17
|
+
typeof window.document.createElement !== 'undefined'
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const isDOM = /* @__PURE__ */ canUseDOM()
|
|
21
|
+
|
|
22
|
+
// Under React Native, we know that we always want to use useLayoutEffect
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the code is running in a React Native environment.
|
|
26
|
+
*
|
|
27
|
+
* @returns Whether the code is running in a React Native environment.
|
|
28
|
+
*
|
|
29
|
+
* @see {@link https://github.com/facebook/react-native/issues/1331 Reference}
|
|
30
|
+
*/
|
|
31
|
+
const isRunningInReactNative = () =>
|
|
32
|
+
typeof navigator !== 'undefined' && navigator.product === 'ReactNative'
|
|
33
|
+
|
|
34
|
+
const isReactNative = /* @__PURE__ */ isRunningInReactNative()
|
|
35
|
+
|
|
36
|
+
const getUseIsomorphicLayoutEffect = () =>
|
|
37
|
+
isDOM || isReactNative ? React.useLayoutEffect : React.useEffect
|
|
38
|
+
|
|
39
|
+
export const useIsomorphicLayoutEffect =
|
|
40
|
+
/* @__PURE__ */ getUseIsomorphicLayoutEffect()
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { useSyncExternalStore } from 'use-sync-external-store'
|
|
2
|
+
import type { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'
|
|
3
|
+
|
|
4
|
+
export const notInitialized = () => {
|
|
5
|
+
throw new Error('uSES not initialized!')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type uSES = typeof useSyncExternalStore
|
|
9
|
+
export type uSESWS = typeof useSyncExternalStoreWithSelector
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import isPlainObject from './isPlainObject'
|
|
2
|
+
import warning from './warning'
|
|
3
|
+
|
|
4
|
+
export default function verifyPlainObject(
|
|
5
|
+
value: unknown,
|
|
6
|
+
displayName: string,
|
|
7
|
+
methodName: string,
|
|
8
|
+
) {
|
|
9
|
+
if (!isPlainObject(value)) {
|
|
10
|
+
warning(
|
|
11
|
+
`${methodName}() in ${displayName} must return a plain object. Instead received ${value}.`,
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prints a warning in the console if it exists.
|
|
3
|
+
*
|
|
4
|
+
* @param {String} message The warning message.
|
|
5
|
+
* @returns {void}
|
|
6
|
+
*/
|
|
7
|
+
export default function warning(message: string) {
|
|
8
|
+
/* eslint-disable no-console */
|
|
9
|
+
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
|
10
|
+
console.error(message)
|
|
11
|
+
}
|
|
12
|
+
/* eslint-enable no-console */
|
|
13
|
+
try {
|
|
14
|
+
// This error was thrown as a convenience so that if you enable
|
|
15
|
+
// "break on all exceptions" in your console,
|
|
16
|
+
// it would pause the execution at this line.
|
|
17
|
+
throw new Error(message)
|
|
18
|
+
/* eslint-disable no-empty */
|
|
19
|
+
} catch (e) {}
|
|
20
|
+
/* eslint-enable no-empty */
|
|
21
|
+
}
|