Skip to content

Instantly share code, notes, and snippets.

@shinchit
Created January 27, 2020 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinchit/a48695dad3ba1d4cf16681022ea6621d to your computer and use it in GitHub Desktop.
Save shinchit/a48695dad3ba1d4cf16681022ea6621d to your computer and use it in GitHub Desktop.
import React from 'react';
import {
Button,
Icon,
} from 'native-base';
import { inject, observer } from 'mobx-react';
import withCommonProps from './withCommonProps'; // HOC ( Higher Order Component )
@inject('dataStore')
@observer
class SomeComponent extends React.Component {
constructor(props) {
super(props);
const { dataStore } = this.props;
// dataStore.fetch() method is loader to data which treat.
this.getData = () => dataStore.fetch();
}
componentWillMount() {
const { showError } = this.props;
this.getData().catch((e) => showError(e));
}
render() {
const {
actionsStore,
showError,
} = this.props;
return (
<Button
onPress={() => {
// dataStore.delete() method is a function to delete data which treat.
dataStore.delete().catch((e) => showError(e));
}}
>
<Icon active name="trash" />
</Button>
);
}
};
const component = withCommonProps(SomeComponent);
export default component;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment