-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Checkbox state persists even after re-rendering of Component #298
Comments
Looks like it's due to the element recycling. I had thought there was an older issue where we adressed this, but maybe not! |
@developit No labels on the issue? 😕 |
Sorry, just working on a regression right now (#297). Can't really prioritize anything else until that's fixed. In the SO question you linked to, someone suggested using a Controlled Component, which I would suggest is the best workaround for now. Using keys to forcibly reset the DOM is a hack - instead, it's better to tell preact/react what you want the DOM to look like ("the checked value of this input should be true") on every render, using state to drive the UI. |
@developit Yes, right. I have followed the same approach and resolved my problem (thanks to the answer on SO question 😄 ) |
This may be related to / solved by a solution to #326 |
@chiragmongia I believe this should be fixed, or at least any diff inaccuracy should be fixed as a result of #326. |
Earlier, I thought the behavior is same in React, so I asked a question on stackoverflow to clear my doubts. The question clearly explains what the exact problem is. The jsfiddles in the question and answer should help.
But with the answer, it seems React has
key
attribute to make it work. When I tried the same using Preact, it didn't solve my problemHow can it be done in Preact? Or is this an issue with preact?
PS- I'm not really sure if this belongs to preact or preact-compat, so I'm posting it here.
@developit
The text was updated successfully, but these errors were encountered: