Skip to content

Instantly share code, notes, and snippets.

@advorkina
Last active February 23, 2019 18:22
Show Gist options
  • Save advorkina/6962381397395ca8f8703f2d949f04dc to your computer and use it in GitHub Desktop.
Save advorkina/6962381397395ca8f8703f2d949f04dc to your computer and use it in GitHub Desktop.
import { inject, observer } from 'mobx-react/native';
// other imports
// because of the @inject line we will get observableStore to our props
// because of the @observer line the component will be rerendered each time store will get updated
@inject('observableStore')
@observer
export default class SubscribeComponent extends Component<{},{}> {
// bla bla bla code
render() {
// and here is the property!!
const property = this.props.observableStore.property;
const smthImportant = this.getSmthImportant(property);
return (<ChildComponent important={smthImportant}/>);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment