diff --git a/README.md b/README.md index 94e9dfc..21e9892 100644 --- a/README.md +++ b/README.md @@ -479,7 +479,7 @@ export const withState =
( } render() { - const { ...remainingProps } = this.props; + const remainingProps = Object.assign({}, this.props); const { count } = this.state; return ( @@ -556,7 +556,7 @@ export const withErrorBoundary =
(
}
render() {
- const { children, ...remainingProps } = this.props;
+ const { children, ...remainingProps } = this.props as any;
const { error } = this.state;
if (error) {
@@ -958,29 +958,30 @@ describe('Todos Logic', () => {
### Create Root State and Root Action Types
#### `RootState` - interface representing redux state tree
-Can be imported in connected components to provide type-safety to Redux `connect` function
+Can be imported in connected components to provide type-safety to Redux `connect` function.
+
+Because the RootState is the sum of it's reducers' return types (plus any store Enhancers we may choose to append), TypeScript can infer its shape entirely from Lookup Types and `ReturnType<>`.
```tsx
import { combineReducers } from 'redux';
-import { routerReducer, RouterState } from 'react-router-redux';
-
-import { countersReducer, CountersState } from '@src/redux/counters';
-import { todosReducer, TodosState } from '@src/redux/todos';
+import { routerReducer } from 'react-router-redux';
-interface StoreEnhancerState { }
-
-export interface RootState extends StoreEnhancerState {
- router: RouterState;
- counters: CountersState;
- todos: TodosState;
-}
+import { countersReducer } from '@src/redux/counters';
+import { todosReducer} from '@src/redux/todos';
import { RootAction } from '@src/redux';
-export const rootReducer = combineReducers (
}
render() {
- const { children, ...remainingProps } = this.props;
+ const { children, ...remainingProps } = this.props as any;
const { error } = this.state;
if (error) {
diff --git a/playground/src/hoc/with-state.tsx b/playground/src/hoc/with-state.tsx
index d891a4b..fef2e38 100644
--- a/playground/src/hoc/with-state.tsx
+++ b/playground/src/hoc/with-state.tsx
@@ -31,7 +31,7 @@ export const withState = (
}
render() {
- const { ...remainingProps } = this.props;
+ const remainingProps = Object.assign({}, this.props);
const { count } = this.state;
return (
diff --git a/playground/src/redux/root-reducer.ts b/playground/src/redux/root-reducer.ts
index 5720aa8..e208aa7 100644
--- a/playground/src/redux/root-reducer.ts
+++ b/playground/src/redux/root-reducer.ts
@@ -1,20 +1,19 @@
import { combineReducers } from 'redux';
-import { routerReducer, RouterState } from 'react-router-redux';
+import { routerReducer } from 'react-router-redux';
-import { countersReducer, CountersState } from '@src/redux/counters';
-import { todosReducer, TodosState } from '@src/redux/todos';
-
-interface StoreEnhancerState { }
-
-export interface RootState extends StoreEnhancerState {
- router: RouterState;
- counters: CountersState;
- todos: TodosState;
-}
+import { countersReducer } from '@src/redux/counters';
+import { todosReducer} from '@src/redux/todos';
import { RootAction } from '@src/redux';
-export const rootReducer = combineReducers