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

[BUG] - DatePicker - Hydration failed because the server rendered HTML didn't match the client. #5000

Open
fereline0 opened this issue Mar 7, 2025 · 3 comments

Comments

@fereline0
Copy link

HeroUI Version

2.7.2

Describe the bug

When reloading a page, when granularity contains something that will add a time selection, an error appears: Hydration failed because the server rendered HTML didn't match the client. As a result, this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used.

The error description contains:

...
  <Form3 validationErrors={undefined}>
    <Form2 validationErrors={undefined} ref={null} validationBehavior="native">
      <form noValidate={false} ref={{current:null}} className="flex flex-...">
        <HeroUI.Input>
          <DatePicker2 label="Expires" granularity="minute" value={{calendar:{...}, ...}} ...>
            <DateInput2 as={undefined} label="Expires" ref={{current:null}} inputRef={undefined} description={undefined} ...>
              <HeroUI.DateInputGroup as={undefined} label="Expires" description={undefined} endContent={<HeroUI.Button>} ...>
                <div data-slot="base" data-required={undefined} data-disabled={undefined} data-readonly={undefined} ...>
                  <div onKeyDown={function} onClick={function onClick} onPointerDown={function} onMouseDown={function} ...>
                    <span>
                      <div ref={{current:null}} data-slot="inner-wrapper" className="flex items...">
                        <HeroUI.DateInputField classNames={undefined} inputProps={{type:"text", ...}} ...>
                          <div data-slot="input-field" data-invalid={undefined} id="react-aria..." data-open={undefined} ...>
                            <DateInputSegment>
                              <DateInputSegment>
                                <DateInputSegment>
                                  <DateInputSegment>
                                    <DateInputSegment>
                                      <DateInputSegment>
                                        <DateInputSegment>
                                          <DateInputSegment>
                                            <DateInputSegment>
                                              <DateInputSegment classNames={undefined} segment={{type:"literal", ...}} ...>
                                                <div
                                                  aria-hidden={true}
                                                    ref={{current:null}}
                                                      className={"group first:-ml-0.5 [&:not(:first-child)]:-ml-1 px-0.5 my-auto box-content ..."}
                                                        data-editable={undefined}
                                                          data-invalid={undefined}
                                                            data-placeholder={undefined}
                                                              data-slot="segment"
                                                                data-type="literal"
                                                                  style={{}}
                                                                    >
                                                                      ...
                                                                        ...
                                                                          ...
                                                                            ...
                                                                              ...
+                                                                      {" "}
-                                                                      {" "}

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Add DatePicker component
  2. Pass everything that adds time to the granularity props, for example granularity="minutes"

Expected behavior

Absence of this error.

Screenshots or Videos

No response

Operating System Version

Linux

Browser

Firefox

@fereline0
Copy link
Author

solution
granularity={isSSR ? "day" : "second"}

@wingkwong
Copy link
Member

please share a sandbox instead.

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

No branches or pull requests

2 participants