Skip to content

Instantly share code, notes, and snippets.

@FreddyPoly
Created June 28, 2019 16:38
Show Gist options
  • Save FreddyPoly/ef6c50944f226abc77dd33770e4bde97 to your computer and use it in GitHub Desktop.
Save FreddyPoly/ef6c50944f226abc77dd33770e4bde97 to your computer and use it in GitHub Desktop.
[REACT NATIVE] Mobx Component Usage Example
import * as React from "react"
import { View } from "react-native"
import { ApiStore } from "../../services/api/api-store"
import { inject } from "mobx-react"
export interface FirstExampleScreenProps extends NavigationScreenProps<{}> {
apiStore: ApiStore,
}
@inject("apiStore")
export class FirstExampleScreen extends React.Component<FirstExampleScreenProps, {}> {
nextScreen = () => this.props.navigation.navigate("secondExample")
componentWillMount = async () => {
const res = await this.props.apiStore.test();
}
render() {
return (
<View>
...
</View>
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment