The exported update-only hook invokes its effect during initial mount
Summary
The exported useUpdateEffect hook contradicts its update-only contract by invoking the callback during its first post-mount effect flush.
Validation source commit: 0337840e9ec0f26840252a658c1a6bf8c1b6dbf1.
Code path
src/hooks/useUpdateEffect.ts:3-7: JSDoc lifecycle claim: the hook runs only on updates, not initial mount.src/hooks/useUpdateEffect.ts:8-16: Implementation falls through the initial-mount branch and invokes effect().src/hooks/index.ts:4-4: Public barrel export for the documented hook.- Repository-local validation artifact: Minimized executable mount/flush witness.
Steps to reproduce
This report is based on a source-control-flow validation against the commit above.
- Check out the source commit listed in this report.
- Inspect the code path and contract anchors listed above.
- Exercise the described boundary/state path: The exported update-only hook invokes its effect during initial mount.
- Compare the observed behavior with the expected contract below.
Validation note: The validation imports the frozen hook and supplies only deterministic React mount primitives. Sequence: initial render -> post-mount effect flush. Expected callback count: 0. Observed: 1. Output: {"sequence":["initial render","post-mount effect flush"],"expectedCallbackCount":0,"actualCallbackCount":1,"violation":true}.
Expected behavior
The implementation should preserve the repository contract described by the documentation, public type, parser, serializer, or sibling implementation anchors above.
Actual behavior
The exported useUpdateEffect hook contradicts its update-only contract by invoking the callback during its first post-mount effect flush.
Existing coverage
I did not find an existing issue or PR title that appears to cover this exact root cause in the pre-submission check.
Suggested fix
Suppress useUpdateEffect's callback during the initial post-mount effect flush.
Suggested tests
- Add a regression test for: The exported update-only hook invokes its effect during initial mount.
- Include the boundary value or state transition described above so the old behavior fails before the fix.
Submitted with Codex.
Source: iib0011/omni-tools