inProgress-team / react-native-meteor

Meteor Reactivity for your React Native application :)
MIT License
693 stars 210 forks source link

Issue using composeAll with createContainer #231

Closed PolGuixe closed 7 years ago

PolGuixe commented 7 years ago

I am trying to use composeAll to compose different containers.

Working:

import UI from './UI';

const MeteorContainer = createContainer(()=>{
   // ... logic
   return {...props}
}, UI)

const ReduxContainer = connect(mapState)(MeteorContainer);

export default ReduxContainer;

Not working:

import UI from './UI';

const MeteorContainer = createContainer(()=>{
   // ... logic
   return {...props}
})

const ReduxContainer = connect(mapState);

export default composeAll(
   MeteorContainer,
   ReduxContainer,
)(UI);

Can createContainer work this way?

PolGuixe commented 7 years ago

I managed to make it work. Thanks @ochicf.

I had to curry createContainer.

This way it works:

import _ from 'lodash'; // You can also do a JS curry. Lodash just makes things nicer ;)
import UI from './UI';

const composableMeteorContainer = _.curry(createContainer, 2)(()=>{
   // ... logic
   return {...props}
})

const reduxComposer = connect(mapState);

export default composeAll(
   composableMeteorContainer,
   redixComposer,
)(UI);