Skip to content

Commit 1c13c24

Browse files
committed
Prevent invalid JSON from throwing uncaught exception
1 parent 3d904ae commit 1c13c24

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

example/src/JsonSchemaFormSuite.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,16 @@ class JsonSchemaFormEditor extends React.Component<Props, State> {
265265
<JSONInput
266266
id='data_schema'
267267
placeholder={
268-
this.props.schema ? JSON.parse(this.props.schema) : {}
268+
this.props.schema
269+
? (() => {
270+
try {
271+
return JSON.parse(this.props.schema);
272+
} catch (e) {
273+
console.error(e);
274+
return {};
275+
}
276+
})()
277+
: {}
269278
}
270279
locale={locale}
271280
height='550px'

0 commit comments

Comments
 (0)