Skip to content

Commit dc030d6

Browse files
committed
Add dontReenableAfterSuccess prop to support other default states besides enabled
1 parent de29340 commit dc030d6

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ Id of the form to submit (useful if the button is not directly inside the form).
139139

140140
Whether click event should bubble when in loading state
141141

142+
##### dontReenableAfterSuccess
143+
144+
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 `''`.
145+
142146
### Methods
143147

144148
##### loading()

src/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const ProgressButton = createReactClass({
2222
onSuccess: PropTypes.func,
2323
state: PropTypes.oneOf(Object.keys(STATE).map(k => STATE[k])),
2424
type: PropTypes.string,
25-
shouldAllowClickOnLoading: PropTypes.bool
25+
shouldAllowClickOnLoading: PropTypes.bool,
26+
dontReenableAfterSuccess: PropTypes.bool
2627
},
2728

2829
getDefaultProps () {
@@ -34,7 +35,8 @@ const ProgressButton = createReactClass({
3435
onClick () {},
3536
onError () {},
3637
onSuccess () {},
37-
shouldAllowClickOnLoading: false
38+
shouldAllowClickOnLoading: false,
39+
dontReenableAfterSuccess: false
3840
}
3941
},
4042

@@ -48,7 +50,7 @@ const ProgressButton = createReactClass({
4850
if (nextProps.state === this.props.state) { return }
4951
switch (nextProps.state) {
5052
case STATE.SUCCESS:
51-
this.success()
53+
this.success(null. this.props.dontReenableAfterSuccess)
5254
return
5355
case STATE.ERROR:
5456
this.error()

0 commit comments

Comments
 (0)