Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 5 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -34,7 +35,8 @@ const ProgressButton = createReactClass({
onClick () {},
onError () {},
onSuccess () {},
shouldAllowClickOnLoading: false
shouldAllowClickOnLoading: false,
dontReenableAfterSuccess: false
}
},

Expand All @@ -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()
Expand Down