You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let me first start off by saying I LOVE, LOVE PrimeReact!! Great job on that!
I'm submitting a ... (check one with "x")
[X ] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57
Plunkr Case (Bug Reports)
Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.
Current behavior
When you update state, that changes the "checked" value from true/false then the state of the UI doesn't change. It only seems to properly set the state initially (componentDidMount) and subsequently when using checkUI or UncheckUI. So the UI becomes out of sync with the state.
ALSO - I've looked at the latest source code for InputSwitch and i believe you need to add this... Because you are ONLY updating the DIV widths (on/off sizes) in the componentWillMount - which I think is only called once initially, that leaves subsequent updates (via prop changes, not using the UI control) will not sync the UI.
*** NEED TO ADD THIS TO THE InputSwitch component ***
componentWillReceiveProps(nextProps) {
if (this.props.checked !== nextProps.checked) {
if (nextProps.checked) {
this.checkUI();
} else {
this.uncheckUI();
}
}
}
Expected behavior
State and UI should always be in SYNC.
Minimal reproduction of the problem with instructions
Just create another way to update state value, that passes as checked value to the InputSwitch.
Please tell us about your environment:
React version:
React 16.x
PrimeReact version:
1.5.2
**Browser:**Chrome
Language: [all | TypeScript X.X | ES6/7 | ES5]
The text was updated successfully, but these errors were encountered:
cagataycivici
changed the title
InputSwitch doesn't update when value changes via props (outside of UI click)
InputSwitch doesn't update programmatically
Jul 18, 2018
I've reimplemeted the inputswitch as below and checked this case as well, it works with the new one. It does not use any lifecycle callback as there is no need for this component.
Let me first start off by saying I LOVE, LOVE PrimeReact!! Great job on that!
I'm submitting a ... (check one with "x")
Plunkr Case (Bug Reports)
Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.
https://plnkr.co/edit/C6qjkdLtbmy92Hogdnjb?p=preview
Current behavior
When you update state, that changes the "checked" value from true/false then the state of the UI doesn't change. It only seems to properly set the state initially (componentDidMount) and subsequently when using checkUI or UncheckUI. So the UI becomes out of sync with the state.
ALSO - I've looked at the latest source code for InputSwitch and i believe you need to add this... Because you are ONLY updating the DIV widths (on/off sizes) in the componentWillMount - which I think is only called once initially, that leaves subsequent updates (via prop changes, not using the UI control) will not sync the UI.
*** NEED TO ADD THIS TO THE InputSwitch component ***
componentWillReceiveProps(nextProps) {
if (this.props.checked !== nextProps.checked) {
if (nextProps.checked) {
this.checkUI();
} else {
this.uncheckUI();
}
}
}
Expected behavior
State and UI should always be in SYNC.
Minimal reproduction of the problem with instructions
Just create another way to update state value, that passes as checked value to the InputSwitch.
Please tell us about your environment:
React version:
React 16.x
PrimeReact version:
1.5.2
**Browser:**Chrome
Language: [all | TypeScript X.X | ES6/7 | ES5]
The text was updated successfully, but these errors were encountered: