Skip to main content
Version: Current (v7.0.0-beta.3)

Custom FieldTemplate and WrapIfAdditionalTemplate handle the keyNotAllowed prop

Detect​

  • Your custom FieldTemplate renders WrapIfAdditionalTemplate and lists the props it passes one by one.
  • Your custom WrapIfAdditionalTemplate spreads the props it doesn't use onto a DOM element, and React warns in the console about an unknown keyNotAllowed prop on that element.

Change​

A custom FieldTemplate adds keyNotAllowed to the props it forwards, or the forbidden key isn't marked:

<WrapIfAdditionalTemplate
hasErrors={hasErrors}
keyName={keyName}
+ keyNotAllowed={keyNotAllowed}
{...otherForwardedProps}
>

The other props it forwards, hasErrors and keyName, are covered in Custom field, array and object templates take their error state from hasErrors.

A custom WrapIfAdditionalTemplate that spreads the rest of its props leaves keyNotAllowed out:

-const { children, label, ...rest } = props;
+const { children, label, keyNotAllowed, ...rest } = props;
return <div {...rest}>{children}</div>;

Verify​

  • A forbidden key's row shows The key "%1" is not allowed here.
  • React logs no unknown-prop warning for keyNotAllowed.

Also read: