V11: @primereact/headless: InputOtp value is not reflecting immediatly

オープン
#8,404 コメント 2 件 リアクション 0 件 担当者 1 名 GitHub で見る

@dmitrii-nikiforov がすでに取り組んでいます。

2026年1月4日 から。

  • #8405 @dmitrii-nikiforov による — マージされずにクローズ

評価

この issue はまだ評価されていません。

説明

Type: Bug
Describe the bug
Description

When using the InputOtp component, the value in the onValueChange callback is returned incorrectly.

Actual Behavior

The changes made are not applied immediatly, only at the next change.
Image

Image Image
Additional information

This is due to the operation of the useState hook.

The set function only updates the state variable for the next render. If you read the state variable after calling the set function, you will still get the old value that was on the screen before your call.

Reproducer

No response

System Information
System:
  OS: macOS 26.0.1
  CPU: (8) arm64 Apple M3
  Memory: 530.36 MB / 24.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 22.14.0 - /usr/local/bin/node
  Yarn: 1.22.22 - /usr/local/bin/yarn
  npm: 10.9.2 - /usr/local/bin/npm
  pnpm: 10.18.3 - /Users/dnikiforov/Library/pnpm/pnpm
  bun: 1.3.0 - /Users/dnikiforov/.bun/bin/bun
Browsers:
  Firefox: 139.0.1
  Safari: 26.0.1
Steps to reproduce the behavior
  1. Install [email protected]
  2. Import InputOtp component into the project
  3. Insert the code from the basic example
  4. Add a state variable for the input value
  5. Add the onValueChange prop to component
  6. In the onValueChange callback, call the state variable set function
  7. look in the react devtools
Expected behavior

the value changes immediately

主要言語
CSS
スター
8.3k
フォーク
1.2k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

primefaces/primereact のほかの issue

primefaces/primereact の issue をすべて見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。