UNPKG

ilp-core

Version:

ILP core module managing ledger abstraction

31 lines (26 loc) 764 B
import React, {Component, PropTypes} from 'react' import {reset} from 'redux-form' // Always use after @connect it uses the success prop // TODO asking for formKey because redux-form formKey is empty for some reason export default function resetFormOnSuccess(formKey) { return (DecoratedComponent) => { return class extends Component { static propTypes = { dispatch: PropTypes.func, success: PropTypes.bool } shouldComponentUpdate(nextProps) { if (!this.props.success && nextProps.success) { this.props.dispatch(reset(formKey)) return false } return true } render() { return ( <DecoratedComponent {...this.props} /> ) } } } }