V11: @primereact/headless: InputOtp value is not reflecting immediatly
评估
这个 Issue 还没有评估数据。
描述
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.
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
- Install [email protected]
- Import InputOtp component into the project
- Insert the code from the basic example
- Add a state variable for the input value
- Add the onValueChange prop to component
- In the onValueChange callback, call the state variable set function
- look in the react devtools
Expected behavior
the value changes immediately
- 主要语言
- CSS
- 星标
- 8.3k
- 派生
- 1.2k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
primefaces/primereact 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
primefaces/primereact#8552 ·
-
难度 1/5 1-3 小时 新手友好度 88/100
primefaces/primereact#8550 ·
-
Row checkbox selection tick is invisible in Landing Page Theme section可能已有人在做 @Prakash1185 于 173 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
primefaces/primereact#8545 ·
-
Dependency conflict between jspdf v4 and jspdf-autotable during npm install可能已有人在做 @Kamran92 于 187 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
primefaces/primereact#8537 ·
-
难度 3/5 1-2 天 新手友好度 58/100
primefaces/primereact#8551 ·