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

context #65506

Open
hoseale opened this issue May 8, 2024 · 0 comments
Open

context #65506

hoseale opened this issue May 8, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template.

Comments

@hoseale
Copy link

hoseale commented May 8, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/confident-field-df495n?file=%2Fapp%2Fpage.tsx%3A6%2C1

To Reproduce

  1. Wrap layout.tsx with a contextProvider, passing state and setState.
  2. Add a client component in the page.tsx.
  3. In the client component, use setState with a function as the parameter, sometimes the function may execute twice.
image

Current vs. Expected behavior

I hope the function inside setState executes only once

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

Not sure

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

next dev (local)

Additional context

No response

@hoseale hoseale added the bug Issue was opened via the bug report template. label May 8, 2024
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.
Projects
None yet
Development

No branches or pull requests

1 participant