Created
January 27, 2020 23:27
-
-
Save shinchit/a48695dad3ba1d4cf16681022ea6621d to your computer and use it in GitHub Desktop.
This file contains 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 { | |
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