This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-12-26 16:54:28 -08:00
|
|
|
import { injectIntl } from 'react-intl';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2017-12-23 22:16:45 -08:00
|
|
|
// Merges react-redux props.
|
|
|
|
export function mergeProps (stateProps, dispatchProps, ownProps) {
|
|
|
|
Object.assign({}, ownProps, {
|
|
|
|
dispatch: Object.assign({}, dispatchProps, ownProps.dispatch || {}),
|
|
|
|
state: Object.assign({}, stateProps, ownProps.state || {}),
|
|
|
|
});
|
|
|
|
}
|
2017-12-26 16:54:28 -08:00
|
|
|
|
|
|
|
// Connects a component.
|
|
|
|
export function wrap (Component, mapStateToProps, mapDispatchToProps, options) {
|
|
|
|
const withIntl = typeof options === 'object' ? options.withIntl : !!options;
|
|
|
|
return (withIntl ? injectIntl : i => i)(connect(mapStateToProps, mapDispatchToProps, mergeProps)(Component));
|
|
|
|
}
|