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

[v1] Prop id did not match #375

Closed
adaboese opened this issue Jan 10, 2024 · 7 comments
Closed

[v1] Prop id did not match #375

adaboese opened this issue Jan 10, 2024 · 7 comments

Comments

@adaboese
Copy link

Describe the bug and the expected behavior

Trying out v1 and getting error:

Warning: Prop aria-describedby did not match.
Server: ":R1cop:-form-item-description" Client: ":Rkop:-form-item-description"

Appears that server IDs do not match client IDs.

Conform version

v1.0.0

Steps to Reproduce the Bug or Issue

const MewPasswordForm = () => {
  const fetcher = useFetcher<typeof action>();

  const [form, fields] = useForm({
    lastResult: fetcher.data,
    onValidate({ formData }) {
      return parseWithZod(formData, { schema: FormDataZodSchema });
    },
  });

  const submitting = fetcher.state === 'submitting';

  return (
    <FormProvider context={form.context}>
      <fetcher.Form
        className={formRoot()}
        method="post"
        {...getFormProps(form)}
      >
        {form.errors ? (
          <div className={formMessage({ type: 'error' })}>{form.errors[0]}</div>
        ) : null}

        <Form.Field input={fields.password}>
          <Form.Item>
            <Form.Label>New Password</Form.Label>
            <Form.Control>
              <Input
                disabled={submitting}
                placeholder=""
                type="password"
                {...getInputProps(fields.password)}
              />
            </Form.Control>
            <Form.Message />
          </Form.Item>
        </Form.Field>

        <Wrap>
          <Button
            alignSelf="flex-start"
            className={css({
              display: 'block',
              width: '100%',
            })}
            disabled={submitting}
            name="intent"
            type="submit"
            value="new-password"
          >
            Update Password
          </Button>
        </Wrap>
      </fetcher.Form>
    </FormProvider>
  );
};

What browsers are you seeing the problem on?

No response

Screenshots or Videos

No response

Additional context

No response

@edmundhung
Copy link
Owner

All ids generated are just prefixed with an id created using the useId() hook. The id is stable unless the component tree is different as mentioned in the docs:

With server rendering, useId requires an identical component tree on the server and the client. If the trees you render on the server and the client don’t match exactly, the generated IDs won’t match.

I am not sure if Conform has any impact here as the only thing you rendered using Conform is the <FormProvider /> and it is working fine during my tests so far. It would be great if you can share a repo on codesandbox / stackblitz.

@adaboese
Copy link
Author

adaboese commented Jan 11, 2024

I figured out the issue and it was indeed a mistake in my own code. Thanks!

@adaboese
Copy link
Author

The v1.0.0 is doing something weird.

The moment I add useForm from v1.0.0 to my component tree, a bunch of other components (entirely unrelated to Conform) start breaking with errors like:

Prop id did not match. Server: "accordion::R4lgp::trigger:What makes a good source article?" Client: "accordion::R29gp::trigger:What makes a good source article?"

@adaboese adaboese changed the title [v1] Prop aria-describedby did not match [v1] Prop id did not match Jan 11, 2024
@adaboese
Copy link
Author

adaboese commented Jan 11, 2024

I have reduced the entire example down to just:

import { Accordion as ArkAccordion } from '@ark-ui/react/accordion';
import { useForm } from '@conform-to/react';
import { useFetcher } from '@remix-run/react';

const Route = () => {
  useFetcher();

  useForm({});

  return <ArkAccordion collapsible />;
};

export default Route;

package.json:

"@ark-ui/react": "^1.2.1",
"@conform-to/react": "1.0.0-pre.6",
"@remix-run/react": "2.4.1",

This gives error:

Warning: Prop id did not match. Server: "accordion::R5gp:" Client: "accordion::R1gp:"

If you comment out useForm, the error goes away.

@adaboese
Copy link
Author

I wonder if related remix-run/react-router#11166. Haven't had a chance to test yet

@edmundhung
Copy link
Owner

Please try this solution suggested from the original issue or upgrade to remix v2.5 to see if it is resolved.

@adaboese
Copy link
Author

Confirming that this is no longer an issue in Remix v2.5. Thank you!

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