Last active
May 7, 2019 21:10
-
-
Save dbuarque/f8dff7d4ac57fbc921e0f0bedc64c79c to your computer and use it in GitHub Desktop.
Minimal Mobx Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'babel-polyfill'; | |
import React, { Component } from 'react' | |
import { | |
View | |
} from 'react-native' | |
import { observer, inject } from 'mobx-react' | |
@inject('appStore') @observer | |
class HomeScreen extends Component { | |
render() { | |
const { appStore } = this.props | |
return ( | |
<View> | |
</View> | |
) | |
} | |
} | |
export default HomeScreen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { Provider } from 'mobx-react' | |
import store from './store' | |
import RootStack from './RootStack' | |
export default (() => ( | |
<Provider appStore={store} > | |
<RootStack /> | |
</Provider> | |
)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { observable, action } from 'mobx' | |
// App Initial State | |
const appStore = { | |
userId: undefined, | |
isAddModalVisible: false, | |
securityFormError: undefined | |
} | |
// create the state | |
export default observable.map(appStore) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment