primefaces / primefaces/primereact
V11: @primereact/headless: InputOtp value is not reflecting immediatly
Open
@dmitrii-nikiforov is already working on this.
Since Jan 4, 2026.
- #8405 by @dmitrii-nikiforov — closed without merging
Type: Bug
- Dominant language
- CSS
- Stars
- 8.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
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 primereact@11.0.0-alpha.7
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.