Skip to content
This repository was archived by the owner on Aug 3, 2022. It is now read-only.

Commit 8d51535

Browse files
fixed bug #6 with switch not toggling with state prop update
Previously when the state prop changed due to an update in the parent component, the switch would not toggle to the correct position. Now, with the use of componentWillReceiveProps, we pass the state prop to the value() method so it can be updated. This will probably work with other, currently immutable props.
1 parent 764023f commit 8d51535

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/coffee/react-bootstrap-switch.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ module.exports = React.createClass
3232
readonly: @_prop('readonly')
3333
indeterminate: @_prop('indeterminate')
3434

35+
componentWillReceiveProps: (nextProps) ->
36+
this.value(nextProps.state)
37+
3538
_prop: (key) ->
3639
if typeof @props[key] == 'undefined'
3740
@defaults[key]

0 commit comments

Comments
 (0)