Skip to content

Commit 83336d0

Browse files
committed
Merge branch 'master' into feature/react-18-initial-compat
# Conflicts: # src/components/Provider.tsx
2 parents 67ead51 + 9021feb commit 83336d0

File tree

5 files changed

+41
-31
lines changed

5 files changed

+41
-31
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Official React bindings for [Redux](https://github.com/reduxjs/redux).
44
Performant and flexible.
55

6-
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/reduxjs/react-redux/CI?style=flat-square) [![npm version](https://img.shields.io/npm/v/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux)
6+
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/reduxjs/react-redux/Tests?style=flat-square) [![npm version](https://img.shields.io/npm/v/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux)
77
[![npm downloads](https://img.shields.io/npm/dm/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux)
88
[![redux channel on discord](https://img.shields.io/badge/[email protected]?style=flat-square)](http://www.reactiflux.com)
99

docs/api/hooks.md

-1
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,3 @@ export function useShallowEqualSelector(selector) {
481481
### Additional considerations when using hooks
482482
483483
There are some architectural trade offs to take into consideration when deciding whether to use hooks or not. Mark Erikson summarizes these nicely in his two blog posts [Thoughts on React Hooks, Redux, and Separation of Concerns](https://blog.isquaredsoftware.com/2019/07/blogged-answers-thoughts-on-hooks/) and [Hooks, HOCs, and Tradeoffs](https://blog.isquaredsoftware.com/2019/09/presentation-hooks-hocs-tradeoffs/).
484-
````

src/components/Provider.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ function Provider({ store, context, children }: ProviderProps) {
3232

3333
useIsomorphicLayoutEffect(() => {
3434
const { subscription } = contextValue
35-
3635
subscription.onStateChange = subscription.notifyNestedSubs
3736
subscription.trySubscribe()
3837

src/components/connect.tsx

+32-14
Original file line numberDiff line numberDiff line change
@@ -264,19 +264,25 @@ function connect<
264264
State = DefaultRootState
265265
>(
266266
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>
267-
): InferableComponentEnhancerWithProps<TStateProps & DispatchProp, TOwnProps>
267+
): InferableComponentEnhancerWithProps<
268+
TStateProps & DispatchProp,
269+
TOwnProps & ConnectProps
270+
>
268271

269272
/* @public */
270273
function connect<no_state = {}, TDispatchProps = {}, TOwnProps = {}>(
271274
mapStateToProps: null | undefined,
272275
mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>
273-
): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>
276+
): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps & ConnectProps>
274277

275278
/* @public */
276279
function connect<no_state = {}, TDispatchProps = {}, TOwnProps = {}>(
277280
mapStateToProps: null | undefined,
278281
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>
279-
): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>
282+
): InferableComponentEnhancerWithProps<
283+
ResolveThunks<TDispatchProps>,
284+
TOwnProps & ConnectProps
285+
>
280286

281287
/* @public */
282288
function connect<
@@ -287,7 +293,10 @@ function connect<
287293
>(
288294
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
289295
mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>
290-
): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>
296+
): InferableComponentEnhancerWithProps<
297+
TStateProps & TDispatchProps,
298+
TOwnProps & ConnectProps
299+
>
291300

292301
/* @public */
293302
function connect<
@@ -300,7 +309,7 @@ function connect<
300309
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>
301310
): InferableComponentEnhancerWithProps<
302311
TStateProps & ResolveThunks<TDispatchProps>,
303-
TOwnProps
312+
TOwnProps & ConnectProps
304313
>
305314

306315
/* @public */
@@ -313,7 +322,7 @@ function connect<
313322
mapStateToProps: null | undefined,
314323
mapDispatchToProps: null | undefined,
315324
mergeProps: MergeProps<undefined, undefined, TOwnProps, TMergedProps>
316-
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>
325+
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>
317326

318327
/* @public */
319328
function connect<
@@ -326,7 +335,7 @@ function connect<
326335
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
327336
mapDispatchToProps: null | undefined,
328337
mergeProps: MergeProps<TStateProps, undefined, TOwnProps, TMergedProps>
329-
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>
338+
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>
330339

331340
/* @public */
332341
function connect<
@@ -338,7 +347,7 @@ function connect<
338347
mapStateToProps: null | undefined,
339348
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
340349
mergeProps: MergeProps<undefined, TDispatchProps, TOwnProps, TMergedProps>
341-
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>
350+
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>
342351

343352
/* @public */
344353
// @ts-ignore
@@ -352,23 +361,29 @@ function connect<
352361
mapDispatchToProps: null | undefined,
353362
mergeProps: null | undefined,
354363
options: ConnectOptions<State, TStateProps, TOwnProps>
355-
): InferableComponentEnhancerWithProps<DispatchProp & TStateProps, TOwnProps>
364+
): InferableComponentEnhancerWithProps<
365+
DispatchProp & TStateProps,
366+
TOwnProps & ConnectProps
367+
>
356368

357369
/* @public */
358370
function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(
359371
mapStateToProps: null | undefined,
360372
mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>,
361373
mergeProps: null | undefined,
362374
options: ConnectOptions<{}, TStateProps, TOwnProps>
363-
): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>
375+
): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps & ConnectProps>
364376

365377
/* @public */
366378
function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(
367379
mapStateToProps: null | undefined,
368380
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
369381
mergeProps: null | undefined,
370382
options: ConnectOptions<{}, TStateProps, TOwnProps>
371-
): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>
383+
): InferableComponentEnhancerWithProps<
384+
ResolveThunks<TDispatchProps>,
385+
TOwnProps & ConnectProps
386+
>
372387

373388
/* @public */
374389
function connect<
@@ -381,7 +396,10 @@ function connect<
381396
mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>,
382397
mergeProps: null | undefined,
383398
options: ConnectOptions<State, TStateProps, TOwnProps>
384-
): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>
399+
): InferableComponentEnhancerWithProps<
400+
TStateProps & TDispatchProps,
401+
TOwnProps & ConnectProps
402+
>
385403

386404
/* @public */
387405
function connect<
@@ -396,7 +414,7 @@ function connect<
396414
options: ConnectOptions<State, TStateProps, TOwnProps>
397415
): InferableComponentEnhancerWithProps<
398416
TStateProps & ResolveThunks<TDispatchProps>,
399-
TOwnProps
417+
TOwnProps & ConnectProps
400418
>
401419

402420
/* @public */
@@ -411,7 +429,7 @@ function connect<
411429
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
412430
mergeProps: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>,
413431
options?: ConnectOptions<State, TStateProps, TOwnProps, TMergedProps>
414-
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>
432+
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>
415433

416434
/**
417435
* Connects a React component to a Redux store.

test/components/connect.spec.tsx

+8-14
Original file line numberDiff line numberDiff line change
@@ -2217,10 +2217,6 @@ describe('React', () => {
22172217
rtl.render(
22182218
<ProviderMock context={context} store={store1}>
22192219
<ProviderMock store={store2}>
2220-
{/*TODO: Since the connect type does not support this advanced usage,
2221-
we will ignore it for the time being and resolve it after merging connect and connectAdvanced
2222-
https://github.com/reduxjs/react-redux/pull/1781 */}
2223-
{/*// @ts-ignore */}
22242220
<Decorated context={context} />
22252221
</ProviderMock>
22262222
</ProviderMock>
@@ -2249,13 +2245,9 @@ describe('React', () => {
22492245
const Decorated = decorator(Container)
22502246

22512247
const store = createStore(() => expectedState)
2252-
22532248
rtl.render(
22542249
<ProviderMock store={store}>
2255-
{/*TODO: Since the connect type does not support this advanced usage,
2256-
we will ignore it for the time being and resolve it after merging connect and connectAdvanced
2257-
https://github.com/reduxjs/react-redux/pull/1781 */}
2258-
{/*// @ts-ignore */}
2250+
{/*@ts-expect-error*/}
22592251
<Decorated context={nonContext} />
22602252
</ProviderMock>
22612253
)
@@ -2297,6 +2289,7 @@ describe('React', () => {
22972289

22982290
const rendered = rtl.render(
22992291
<ProviderMock store={store}>
2292+
{/*@ts-expect-error*/}
23002293
<Decorated store={notActuallyAStore} />
23012294
</ProviderMock>
23022295
)
@@ -2345,7 +2338,6 @@ describe('React', () => {
23452338
</div>
23462339
)
23472340
}
2348-
const ConnectedComp2 = connect((state) => state)(Comp2)
23492341

23502342
type Comp1TStatePropsType = Store1State1Type
23512343
type Comp1NoDispatchType = NoDispatchType
@@ -2392,17 +2384,19 @@ describe('React', () => {
23922384
return state
23932385
}
23942386
}
2387+
const ConnectedComp2 = connect<
2388+
Store2State1Type,
2389+
unknown,
2390+
unknown,
2391+
Store2State1Type
2392+
>((state) => state)(Comp2)
23952393

23962394
const store1 = createStore(reducer1)
23972395
const store2 = createStore(reducer2)
23982396

23992397
const tester = rtl.render(
24002398
<ProviderMock store={store1}>
24012399
<ConnectedComp1>
2402-
{/*TODO: Since the connect type does not support this advanced usage,
2403-
we will ignore it for the time being and resolve it after merging connect and connectAdvanced
2404-
https://github.com/reduxjs/react-redux/pull/1781 */}
2405-
{/*// @ts-ignore */}
24062400
<ConnectedComp2 store={store2} />
24072401
</ConnectedComp1>
24082402
</ProviderMock>

0 commit comments

Comments
 (0)