fix to input a number value to props

This commit is contained in:
Toru Kobayashi 2019-07-14 23:11:08 +09:00
parent 0f2fb5badf
commit 41c00cb0cb
1 changed files with 6 additions and 4 deletions

View File

@ -33,8 +33,6 @@ export default function EditableValue({
if (dataType === 'boolean') {
setEditableValue(target.checked);
overrideValueFn(path, target.checked);
} else if (dataType === 'number') {
setEditableValue(parseFloat(target.value));
} else {
setEditableValue(target.value);
}
@ -60,7 +58,11 @@ export default function EditableValue({
const { key } = event;
if (key === 'Enter') {
if (dataType === 'number') {
overrideValueFn(path, parseFloat(editableValue));
} else {
overrideValueFn(path, editableValue);
}
// Don't reset the pending change flag here.
// The inspected fiber won't be updated until after the next "inspectElement" message.
@ -70,7 +72,7 @@ export default function EditableValue({
setHasPendingChanges(false);
}
},
[path, editableValue, overrideValueFn, value]
[path, editableValue, overrideValueFn, value, dataType]
);
// Render different input types based on the dataType