-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(react): remove unnecessary useSetTimeout's callback calling (#264)
fix #263 # Overview <!-- A clear and concise description of what this pr is about. --> @ssi02014 Thanks for reporting important issue. Could you review this Pull Request too? I remove unnecessary useSetTimeout's callback calling and I added you as co-author in [79fecd9](79fecd9) ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: Gromit (전민재) <[email protected]>
- Loading branch information
Showing
8 changed files
with
47 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@suspensive/react": patch | ||
--- | ||
|
||
perf(react): remove unnecessary useSetTimeout's callback calling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...ges/react/src/hooks/useSetTimeout.spec.ts → packages/react/src/hooks/useTimeout.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useEffect, useRef } from 'react' | ||
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect' | ||
|
||
export const useTimeout = (fn: () => void, ms: number) => { | ||
const fnRef = useRef(fn) | ||
|
||
useIsomorphicLayoutEffect(() => { | ||
fnRef.current = fn | ||
}, [fn]) | ||
|
||
useEffect(() => { | ||
const id = setTimeout(fnRef.current, ms) | ||
return () => clearTimeout(id) | ||
}, [ms]) | ||
} |
c09f52a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-git-main-suspensive.vercel.app
suspensive.org
docs-suspensive.vercel.app
docs-seven-omega.vercel.app
www.suspensive.org
c09f52a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
visualization – ./websites/visualization
visualization-suspensive.vercel.app
visualization.suspensive.org
visualization-git-main-suspensive.vercel.app