react-component / react-component/trigger

error of using goNextStatus in useVisibleStatus.ts

Open
#261 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
391
Forks
245
PR merge metrics
No merged PRs in 30d

Description

Checking goNextStatus() in useVisibleStatus.ts,
the source code look like this, for the switch condition, should we use prev instead of status?
function goNextStatus(callback?: () => void) {
cancelRaf();
rafRef.current = raf(() => {
// Only align should be manually trigger
setStatus((prev) => {
switch (status) { // should we use switch(prev) as it may be possible that react will combine multi setStatus together
case 'align':
return 'motion';
case 'motion':
return 'stable';
default:
}

    return prev;
  });

  callback?.();
});

}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with useVisibleStatus.ts and read goNextStatus, especially the setStatus updater and its switch condition. Check how React batches these status updates and whether the closure value can differ from the updater's prev value. Confirm the intended status progression and validate the behavior with the repository's relevant existing checks, if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.