-
-
Notifications
You must be signed in to change notification settings - Fork 136
Description
Parsing <input type="checkbox" checked /> gives this warning:
You provided a checked prop to a form field without an onChange handler. This will render a read-only field. If the field should be mutable use defaultChecked. Otherwise, set either onChange or readOnly.
Parsning <input type="text" value="initial value" /> gives this warning:
You provided a value prop to a form field without an onChange handler. This will render a read-only field. If the field should be mutable use defaultValue. Otherwise, set either onChange or readOnly.
We made an attempt to fix in the replace method:
if (node.type === 'tag' && node.name === 'input') {
if (node.attribs.type === 'text') {
node.attribs.defaultValue = node.attribs.value
delete node.attribs['value']
}
if (node.attribs.type === 'checkbox') {
node.attribs.defaultChecked = node.attribs.checked
delete node.attribs['checked']
}
}
This seems to work, but not sure if it's the best. Maybe it would be good for support for this case in the package? I see there is something similar dom-to-react for textarea.