forked from reduxjs/react-redux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert tests to use react-testing-library instead of Enzyme (reduxjs…
…#998) * Update React to 16.4.2 * Restore other test changes from 5.1.0-test commit * Fix tests that fail due to use of a string ref * Disable <StrictMode> tests for now * Add react-testing-library * Convert Provider tests to RTL * Convert Connect tests to RTL * Remove uses of Enzyme and getTestDeps * Remove Enzyme and react-test-renderer packages * Fix a test lint error * Disable lint warnings about componentWillReceiveProps
- Loading branch information
1 parent
73691e5
commit 56ae947
Showing
43 changed files
with
1,215 additions
and
26,189 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import PropTypes from 'prop-types' | ||
import {Component, createContext, createElement} from 'react'; | ||
|
||
const context = createContext({}); | ||
|
||
export const {Consumer} = context; | ||
const {Provider} = context; | ||
|
||
export default class ReduxProvider extends Component { | ||
constructor(props) { | ||
super(props); | ||
const {store, isSSR} = props; | ||
this.state = {state: store.getState(), dispatch: store.dispatch}; | ||
|
||
if (!isSSR) { | ||
this.subscription = store.subscribe(() => { | ||
this.setState({state: store.getState()}); | ||
}); | ||
} | ||
} | ||
|
||
componentWillUnmount() { | ||
this.subscription && this.subscription(); | ||
} | ||
|
||
render() { | ||
return createElement(Provider, {value: this.state, children: this.props.children}); | ||
} | ||
} | ||
|
||
ReduxProvider.propTypes = { | ||
children: PropTypes.element.isRequired, | ||
isSSR: PropTypes.bool, | ||
store: PropTypes.shape({ | ||
subscribe: PropTypes.func.isRequired, | ||
dispatch: PropTypes.func.isRequired, | ||
getState: PropTypes.func.isRequired | ||
}), | ||
}; | ||
|
||
ReduxProvider.defaultProps = { | ||
isSSR: false, | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.