Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Received false for a non-boolean attribute dirty #155

Closed
danielweinmann opened this issue Feb 13, 2023 · 2 comments
Closed

Warning: Received false for a non-boolean attribute dirty #155

danielweinmann opened this issue Feb 13, 2023 · 2 comments

Comments

@danielweinmann
Copy link
Contributor

Another warning I came across is

Warning: Received `false` for a non-boolean attribute `dirty`.

If you want to write it to the DOM, pass a string instead: dirty="false" or dirty={value.toString()}.

If you used to conditionally omit it with dirty={condition && value}, pass dirty={condition ? value : undefined} instead.

which is related to me overriding renderField

export default function Form<Schema extends FormSchema>(
  props: FormProps<Schema>
) {
  return (
    <BaseForm
      className="flex flex-col space-y-6"
      fieldComponent={Field}
      labelComponent={Label}
      inputComponent={Input}
      multilineComponent={TextArea}
      selectComponent={Select}
      radioComponent={Radio}
      radioGroupComponent={RadioGroup}
      radioWrapperComponent={InputWrapper}
      checkboxWrapperComponent={InputWrapper}
      checkboxComponent={Checkbox}
      buttonComponent={SubmitButton}
      globalErrorsComponent={Errors}
      errorComponent={Error}
      renderField={({ Field, ...props }) => {
        const { name, label, required } = props;
        return (
          <Field key={name.toString()} {...props}>
            {({ Label, SmartInput, Errors }) => (
              <>
                <SmartInput {...props} />
                <Label>
                  {label}
                  {required && <sup>*</sup>}
                </Label>
                <Errors />
              </>
            )}
          </Field>
        );
      }}
      {...props}
    />
  );
}

Originally posted by @jjanyan in #154 (comment)

@danielweinmann
Copy link
Contributor Author

Hey, @jjanyan! I just realized that you're passing {...props} to SmartInput in your example, and that's what's causing the warning :)

You shouldn't pass these props to it. Just render <SmartInput /> and you're good to go.

@jjanyan
Copy link

jjanyan commented Feb 13, 2023

Ah. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants