Last active
February 27, 2017 02:45
-
-
Save hanipcode/d64659f854a7de7d42b11c6607f0da50 to your computer and use it in GitHub Desktop.
render error
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
| // | |
| // .... sisa aplikasi | |
| //fungsi render | |
| render() { | |
| const { formReducer } = this.props; | |
| // cek kalau field error ada isinya | |
| const isError = formReducer.get('error').size > 0 | |
| // kalau mau render full page error atau redirect tinggal : | |
| if (isError) { | |
| return (<ErrorPage ...props />) | |
| } | |
| // atau kalau mau mengeluarkan popup daripada pake error page bisa | |
| return ( | |
| <View> | |
| //jika is Error true, render popup Error | |
| {isError && | |
| <ErrorPopup ...props /> | |
| } | |
| <PageComponent /> | |
| </View> | |
| ) | |
| } | |
| //jangan lupa pake mapStateToProps dan connect | |
| const mapStateToProps = state => ({ | |
| formReducer: state.formReducer | |
| }); | |
| connect(mapStateToProps)(YourComponent) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment