Skip to content

Commit adf3836

Browse files
author
Dimitri Kopriwa
committed
fix(withRedux): using constructor to initialize state
1 parent 6d0b287 commit adf3836

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Wrapper/utils/tests/withRedux.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import withRedux from '../withRedux';
44

55
describe('withRedux', () => {
66
const mockRedux = {
7-
applyMiddleWare: () => jest.fn(),
7+
applyMiddleware: () => jest.fn(),
88
createStore: jest.fn(),
99
compose: jest.fn(),
1010
};

src/Wrapper/utils/withRedux.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ const withRedux = ({ redux, 'react-redux': reactRedux }, reducer) => (Component)
1212
}
1313

1414
/* eslint-disable no-underscore-dangle, function-paren-newline */
15-
componentWillMount() {
15+
constructor(props) {
16+
super(props);
1617
const { applyMiddleware, createStore, compose } = redux;
1718
const middleware = [];
1819
const composeEnhancers = typeof window === 'object'
1920
&& window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
2021
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
2122
// Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
2223
}) : compose;
23-
2424
const enhancer = composeEnhancers(applyMiddleware(...middleware),
2525
// other store enhancers if any
2626
);
2727

2828
const store = createStore(reducer, enhancer);
29-
this.setState({
29+
this.state = {
3030
store,
31-
});
31+
};
3232
}
3333
/* eslint-enable no-underscore-dangle, function-paren-newline */
3434

0 commit comments

Comments
 (0)