Ensure that connected containers get a System in mapStateToProps props

This will allow us to avoid system utility handaround in
connected containers.
This commit is contained in:
Kyle Shockey
2017-11-16 20:16:45 -08:00
parent 7624d6b5fc
commit 2ce199c151
2 changed files with 58 additions and 2 deletions

View File

@@ -20,9 +20,12 @@ const RootWrapper = (reduxStore, ComponentToWrap) => class extends Component {
}
const makeContainer = (getSystem, component, reduxStore) => {
const mapStateToProps = component.prototype.mapStateToProps || function(state) {
return {state}
const mapStateToProps = function(state, ownProps) {
const propsForContainerComponent = Object.assign({}, ownProps, getSystem())
const ori = component.prototype.mapStateToProps || (state => state.toJS())
return ori(state, propsForContainerComponent)
}
let wrappedWithSystem = SystemWrapper(getSystem, component, reduxStore)
let connected = connect( mapStateToProps )(wrappedWithSystem)
if(reduxStore)