Two packages with default export


I’m trying meteor with React native Using this plug-in :

and I am using for navigation.

it requires to do : export default StackNavigator({ … })

now I also want to use createContainer from the plugin, it also require :
export default createContainer(…)

obviously only one Default export is allowed, how am I supposed to managed this situation ?


You have to think of StackNavigator and createContainer as returning React components. Once you realize this, you can realize that they are composable just like any other React components.

1 Like

Now that I’m at a proper code authoring device :slight_smile:

import React from 'react';
import { View, Text } from 'react-native';
import { createContainer } from 'react-native-meteor';
import { StackNavigator } from 'react-navigation';

const FirstScreen = ({things}) => (<View><Text>Screen #1, Should Display Things</Text></View>);
const SecondScreen = ({posts}) => (<View><Text>Screen #2, should display posts</Text></View>);

const FirstScreenContainer = createContainer(() => ({
    things: ThingsCollection.find(),
}), FirstScreen);

const SecondScreenContainer = createContainer(() => ({
    posts: PostsCollection.find(),
}), FirstScreen);

export default StackNavigator({
    FirstScreen: FirstScreenContainer,
    SecondScreen: SecondScreenContainer,

This is just an example and you’ll need to improvise to suit your app of course

1 Like

Thank you for your answer.

well may be I did not understand well, still I couldn’t manage to make createContainer work without “Export Default”.

I ended up separating createContainer with StackNavigator in two higher level components.

Since we’re at it, is there a best practice regarding using createContainer/withTracker with react ?

I mean we could use only one instance of withTracker in the whole app and spreading data to the children, or anytime we need it we can include withTracker in a file, or maybe regroup withTracker according to some logic for a group of react children (I guess this makes the most sense if we have a lot of data to push to react children) .

1 Like