Hi @erikras , thank you for your great library. I am running into some issues with radio buttons in particular.
I want to use a number as the value, but I do not checked the radio button. I clicked and the value was recorded, but the input did not respond.
I smell an === bug, my favorite of all javascript problems. 馃槅
Ah, yes. The problem is that the DOM only gives string values for inputs. e.g. typeof event.target.value === 'string' is always true. You can get around this by adding a
parse={Number} prop to all your Field components. This will convert the string that the DOM gives back into a Number for storage in the JSON. Then the valueFromState === valueProp check will work for deciding which radio button should be checked. Parse docs.
Thank you. To understand that my problem is in number, I spent 16 hours of my life 馃槅
I think you mean "16" hours. 馃ぃ Glad it's remedied!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Ah, yes. The problem is that the DOM only gives string values for inputs. e.g.
typeof event.target.value === 'string'is always true. You can get around this by adding aparse={Number}prop to all yourFieldcomponents. This will convert the string that the DOM gives back into aNumberfor storage in the JSON. Then thevalueFromState === valuePropcheck will work for deciding which radio button should be checked. Parse docs.