From 829de65f3af7eb98fddf7f50adb3757abc8134a1 Mon Sep 17 00:00:00 2001 From: Philip Tzou Date: Sun, 10 Jul 2022 17:24:40 -0700 Subject: [PATCH] fix: option tag should also be valueOnly Fixes #625 --- lib/attributes-to-props.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/attributes-to-props.js b/lib/attributes-to-props.js index 706a7471..da20b79d 100644 --- a/lib/attributes-to-props.js +++ b/lib/attributes-to-props.js @@ -10,9 +10,10 @@ var utilities = require('./utilities'); module.exports = function attributesToProps(attributes) { attributes = attributes || {}; - var valueOnlyInputs = { + var valueOnlyTypes = { reset: true, - submit: true + submit: true, + option: true }; var attributeName; @@ -21,7 +22,7 @@ module.exports = function attributesToProps(attributes) { var propName; var propertyInfo; var props = {}; - var inputIsValueOnly = attributes.type && valueOnlyInputs[attributes.type]; + var typeIsValueOnly = attributes.type && valueOnlyTypes[attributes.type]; for (attributeName in attributes) { attributeValue = attributes[attributeName]; @@ -43,7 +44,7 @@ module.exports = function attributesToProps(attributes) { // https://reactjs.org/docs/uncontrolled-components.html if ( (propName === 'checked' || propName === 'value') && - !inputIsValueOnly + !typeIsValueOnly ) { propName = getPropName('default' + attributeNameLowerCased); }