Skip to content

Commit 9cf462c

Browse files
authored
Fixes crash caused by ValueNodeWrapper rendering incorrect value (#170)
1 parent 551ec41 commit 9cf462c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/ValueNodeWrapper.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export const ValueNodeWrapper: React.FC<ValueNodeProps> = (props) => {
275275
) : (
276276
// Need to re-fetch data type to make sure it's one of the "core" ones
277277
// when fetching a non-custom component
278-
getInputComponent(getDataType(data) as DataType, inputProps)
278+
getInputComponent(data, inputProps)
279279
)
280280

281281
return (
@@ -403,15 +403,15 @@ const getDataType = (value: unknown, customNodeData?: CustomNodeData) => {
403403
return 'invalid'
404404
}
405405

406-
const getInputComponent = (dataType: DataType, inputProps: InputProps) => {
407-
const value = inputProps.value
406+
const getInputComponent = (data: JsonData, inputProps: InputProps) => {
407+
const dataType = getDataType(data)
408408
switch (dataType) {
409409
case 'string':
410-
return <StringValue {...inputProps} value={value as string} />
410+
return <StringValue {...inputProps} value={data as string} />
411411
case 'number':
412-
return <NumberValue {...inputProps} value={value as number} />
412+
return <NumberValue {...inputProps} value={data as number} />
413413
case 'boolean':
414-
return <BooleanValue {...inputProps} value={value as boolean} />
414+
return <BooleanValue {...inputProps} value={data as boolean} />
415415
case 'null':
416416
return <NullValue {...inputProps} />
417417
default:

0 commit comments

Comments
 (0)