diff --git a/README.md b/README.md index c9322e2..095cead 100755 --- a/README.md +++ b/README.md @@ -139,6 +139,10 @@ Id of the form to submit (useful if the button is not directly inside the form). Whether click event should bubble when in loading state +##### dontReenableAfterSuccess + +After the button is put in the `'success'` state, it'll automatically go back to the enabled (`''`) state. Set this prop to `true` if the default state of your button should be something other than `''`. + ### Methods ##### loading() diff --git a/src/index.js b/src/index.js index a873143..a5a0a78 100644 --- a/src/index.js +++ b/src/index.js @@ -22,7 +22,8 @@ const ProgressButton = createReactClass({ onSuccess: PropTypes.func, state: PropTypes.oneOf(Object.keys(STATE).map(k => STATE[k])), type: PropTypes.string, - shouldAllowClickOnLoading: PropTypes.bool + shouldAllowClickOnLoading: PropTypes.bool, + dontReenableAfterSuccess: PropTypes.bool }, getDefaultProps () { @@ -34,7 +35,8 @@ const ProgressButton = createReactClass({ onClick () {}, onError () {}, onSuccess () {}, - shouldAllowClickOnLoading: false + shouldAllowClickOnLoading: false, + dontReenableAfterSuccess: false } }, @@ -48,7 +50,7 @@ const ProgressButton = createReactClass({ if (nextProps.state === this.props.state) { return } switch (nextProps.state) { case STATE.SUCCESS: - this.success() + this.success(null, this.props.dontReenableAfterSuccess) return case STATE.ERROR: this.error()