Skip to content

Server action loading causes hydration error when using react-select #58257

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

Closed
1 task done
kamil-wsiiz opened this issue Nov 9, 2023 · 2 comments
Closed
1 task done
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.

Comments

@kamil-wsiiz
Copy link

kamil-wsiiz commented Nov 9, 2023

Link to the code that reproduces this issue

https://github.com/kamil-wsiiz/server-action-hydration-error

To Reproduce

  1. Create new next.js app
  2. Add server action in page.tsx
import TestSelect from './components/TestSelect';

export default async function Home() {
  'use server';
  await fetch('https://google.com', { cache: 'no-store' });

  return (
    <TestSelect />
  )
}
  1. Create loading.tsx
export default function Loading() {
  return (
    <div>
      loading
    </div>
  );
}
  1. npm i react-select
  2. Create react-select component
"use client";

import Select from "react-select";

export default function TestSelect() {
  const options = [{ value: 123, label: `test` }];

  return (
    <Select options={options} />
  )
}
  1. npm run build && npm run start

Current vs. Expected behavior

Unexpected hydration error appears every few loads

image

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.1.0: Mon Oct  9 21:27:27 PDT 2023; root:xnu-10002.41.9~6/RELEASE_X86_64
Binaries:
  Node: 20.9.0
  npm: 10.1.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.1
  eslint-config-next: 14.0.1
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Additional context

The error appears only in production mode, developer mode works flawlessly. Using this manual https://nextjs.org/docs/messages/react-hydration-error we learn about several solutions, the only working solution is to use next/dynamic, but this is a mediocre solution, because the component appears only after a while.

@kamil-wsiiz kamil-wsiiz added the bug Issue was opened via the bug report template. label Nov 9, 2023
@nextjs-bot
Copy link
Collaborator

This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.

@nextjs-bot nextjs-bot added the stale The issue has not seen recent activity. label May 8, 2025
@nextjs-bot
Copy link
Collaborator

This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding!

@nextjs-bot nextjs-bot closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.
Projects
None yet
Development

No branches or pull requests

2 participants