PrinzAndreVonLandmann
PrinzAndreVonLandmann

Reputation: 315

React-native + mobx how the Index.js should look like

im trying to integrate Mobx(I´m new to Mobx to be honest) to my existing react-native project and one big question I have is how should the indexfile look like?

mine is looking now like this:

Index.js:

import { AppRegistry } from 'react-native';
import App from './../App/App';

AppRegistry.registerComponent('AppName', () => App);

but some tutorials told me that it should look like this:

Index.js:

 {a bunch of imports here...}
 ReactDOM.render(
   <Provider store={store}>
     <App />
   </Provider>,
  document.getElementById('root')
);

but i dont get the second one running.

so my question is how should the index.js look like?

Upvotes: 0

Views: 147

Answers (1)

kingdaro
kingdaro

Reputation: 12018

The AppRegistry.registerComponent accepts a function which returns a component, so it should work if you have that component render the Provider.

const Root = () => (
  <Provider {...stores}>
    <App />
  </Provider>
)

AppRegistry.registerComponent('AppName', () => Root)

Upvotes: 2

Related Questions