Hi, i’m using custom renderers (Jsonforms/core & React v.3.2.1) to render my form with ValidateAndHide
. I track a touched-state to prevent the initial errors being shown that occur once a user enters data into the form. I also utilize the middleware’s UPDATE_ERRORS & UPDATE_DATA to conditionally show and hide errors depending on the touched-state of every Control and pass them to additionalErrors.
(I’m also getting this error without using my middleware)
Once I started adding production data to my definitions, which added a lot more answers, I consistently started getting:
With custom middleware:
Error caught in boundary RangeError: Maximum call stack size exceeded
at validate (chunk-FBNQYE4V.js?v=c243922c:11559:17)
at coreReducer (chunk-FBNQYE4V.js?v=c243922c:11623:17)
at Object.current (useJsonForms.ts:159:22)
at @jsonforms_react.js?v=c243922c:234:74
at mountState (chunk-ZW27HLE7.js?v=c243922c:12025:28)
at Object.useState (chunk-ZW27HLE7.js?v=c243922c:12565:24)
at useState (chunk-MWE3B2LM.js?v=c243922c:1066:29)
at JsonFormsStateProvider (@jsonforms_react.js?v=c243922c:234:53)
at renderWithHooks (chunk-ZW27HLE7.js?v=c243922c:11568:26)
at mountIndeterminateComponent (chunk-ZW27HLE7.js?v=c243922c:14946:21)
Without specifying middleware:
chunk-FBNQYE4V.js?v=c243922c:11559 Uncaught RangeError: Maximum call stack size exceeded
at validate (chunk-FBNQYE4V.js?v=c243922c:11559:17)
at coreReducer (chunk-FBNQYE4V.js?v=c243922c:11623:17)
at Object.defaultMiddleware [as current] (chunk-FBNQYE4V.js?v=c243922c:12331:60)
at @jsonforms_react.js?v=c243922c:234:74
at mountState (chunk-ZW27HLE7.js?v=c243922c:12025:28)
at Object.useState (chunk-ZW27HLE7.js?v=c243922c:12565:24)
at useState (chunk-MWE3B2LM.js?v=c243922c:1066:29)
at JsonFormsStateProvider (@jsonforms_react.js?v=c243922c:234:53)
at renderWithHooks (chunk-ZW27HLE7.js?v=c243922c:11568:26)
at mountIndeterminateComponent (chunk-ZW27HLE7.js?v=c243922c:14946:21)
I have two questions as of right now:
- is it possible to disable validation of
definitions
in the schema? (then everything seems to work fine (NoValidation)) - am I using a good structure for declaring these definitions? Or is there a more efficient one you can suggest? We really need a key-value pair option, as we need to pass a key but show a more descriptive answer to the user.
I haven’t tried thisbut would you suggest doing something like this for my definitions instead?
{
type: 'object'
enum: [{key: 'value1'}, {key1: 'value2'}]
}
Edit: This seems to work fine. It’s no longer crashing, I started checking AJV’s oneOf implemention and it seems like it’s a bunch of recursive if-statements that occur when using it. Although the downside with this enum
approach is that it’s not natively supported in the jsonforms editor.
JsonSchema:
{
type: 'object',
properties: {
companyName: {
type: 'string',
},
organizationNumber: {
type: 'string',
},
streetName: {
type: 'string',
},
coAdress: {
type: 'string',
},
zipCode: {
type: 'string',
},
city: {
type: 'string',
},
country: {
type: 'string',
$ref: '#/definitions/countries',
},
lei: {
type: 'string',
$ref: '#/definitions/yesNo',
},
sni: {
type: 'string',
$ref: '#/definitions/sni',
},
// there are quite a few more properties
},
required: [
// all my required fields
],
definitions: {
yesNo: {
type: 'string',
oneOf: [
{ const: 'yes', title: 'Ja' },
{ const: 'no', title: 'Nej' },
],
},
sni: {
type: 'string',
oneOf: [
{ const: 'key1', title: 'example1' },
{ const: 'key2', title: 'example2' },
// ..... and 600 more keys
],
},
countries: {
type: 'string',
oneOf: [
{ const: 'se', title: 'Sweden' },
{ const: 'dk', title: 'Denmark' },
{ const: 'no', title: 'Norway' },
{ const: 'fi', title: 'Finland' },
// ..... all countries
],
},
},
}
Please let me know if there are any more details I can provide.
Thank you, J