facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
229.32k stars 46.96k forks source link

Dont rerender check-box and radiobox #4583

Closed trquoccuong closed 9 years ago

trquoccuong commented 9 years ago

I make a quiz app with React. When I use logic nextQuiz , all state is ok but this dont change checked info( I dont use any state or props for manage this). My mini project here "https://github.com/trquoccuong/learn-react/tree/master/QuizGame" Problem is it rerender but dont rerender check info screen shot 2015-08-07 at 18 05 06 screen shot 2015-08-07 at 18 05 11 1

I update a small version here https://jsfiddle.net/bsn6ckgv/29/

jimfb commented 9 years ago

Calling setState on a component should cause it to re-render. You can force a re-render by using the forceUpdate function.

This sounds like a usage question rather than a bug in React. We use github issues to track bugs in React, so I'm going to close this out. Feel free to continue the discussion on this thread, or take such discussions to StackOverflow.

trquoccuong commented 9 years ago

This not prolem with setState. It rerendered but the checked info didn't render

zpao commented 9 years ago

@trquoccuong take a look at the documentation on controlled components (http://facebook.github.io/react/docs/forms.html#controlled-components). You will likely want to handle the user checking a box so you can set the checked prop.

trquoccuong commented 9 years ago

I update new version for easy to debug. Everything rerender but the checked status isn't remove. I can set checked prop to it but I think it not need here. Change question all answer changed but status dont . Problem here : I rerender input form but checked not so strange

trquoccuong commented 9 years ago

Now I have solution for that http://stackoverflow.com/questions/31881266/reactjs-rerender-input-but-dont-change-checked-status But I think it should be an improvement