Skip to content

Commit 30d70e9

Browse files
committed
Update connect types to reflect context and store props
1 parent a8fd20e commit 30d70e9

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/components/connect.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,16 @@ function subscribeUpdates(
192192
const initStateUpdates = () => EMPTY_ARRAY
193193

194194
export interface ConnectProps {
195-
reactReduxForwardedRef?: React.ForwardedRef<unknown>
195+
/** A custom Context instance that the component can use to access the store from an alternate Provider using that same Context instance */
196196
context?: ReactReduxContextInstance
197+
/** A Redux store instance to be used for subscriptions instead of the store from a Provider */
197198
store?: Store
198199
}
199200

201+
interface InternalConnectProps extends ConnectProps {
202+
reactReduxForwardedRef?: React.ForwardedRef<unknown>
203+
}
204+
200205
function match<T>(
201206
arg: unknown,
202207
factories: ((value: unknown) => T)[],
@@ -538,7 +543,9 @@ function connect<
538543
// that just executes the given callback immediately.
539544
const usePureOnlyMemo = pure ? useMemo : (callback: () => any) => callback()
540545

541-
function ConnectFunction<TOwnProps>(props: ConnectProps & TOwnProps) {
546+
function ConnectFunction<TOwnProps>(
547+
props: InternalConnectProps & TOwnProps
548+
) {
542549
const [propsContext, reactReduxForwardedRef, wrapperProps] =
543550
useMemo(() => {
544551
// Distinguish between actual "data" props that were passed to the wrapper component,

src/exports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Provider from './components/Provider'
22
import type { ProviderProps } from './components/Provider'
33
import connect, {
44
Connect,
5+
ConnectProps,
56
ConnectedProps,
67
} from './components/connect'
78
import type {

src/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { Action, AnyAction, Dispatch } from 'redux'
88
// import hoistNonReactStatics = require('hoist-non-react-statics');
99
import type { NonReactStatics } from 'hoist-non-react-statics'
1010

11+
import type { ConnectProps } from './components/connect'
12+
1113
export type FixTypeLater = any
1214

1315
export type EqualityFn<T> = (a: T, b: T) => boolean
@@ -116,7 +118,8 @@ export type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> = <
116118
GetLibraryManagedProps<C>,
117119
keyof Shared<TInjectedProps, GetLibraryManagedProps<C>>
118120
> &
119-
TNeedsProps
121+
TNeedsProps &
122+
ConnectProps
120123
>
121124

122125
// Injects props and removes them from the prop requirements.

0 commit comments

Comments
 (0)