Skip to content

Instantly share code, notes, and snippets.

@hanipcode
Last active February 27, 2017 02:45
Show Gist options
  • Select an option

  • Save hanipcode/d64659f854a7de7d42b11c6607f0da50 to your computer and use it in GitHub Desktop.

Select an option

Save hanipcode/d64659f854a7de7d42b11c6607f0da50 to your computer and use it in GitHub Desktop.
render error
//
// .... 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