Gathering detailed insights and metrics for use-constant-handler
Gathering detailed insights and metrics for use-constant-handler
Gathering detailed insights and metrics for use-constant-handler
Gathering detailed insights and metrics for use-constant-handler
npm install use-constant-handler
Typescript
Module System
Node Version
NPM Version
TypeScript (69.55%)
JavaScript (30.45%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
9 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Nov 22, 2021
Latest Version
0.1.9
Package Id
use-constant-handler@0.1.9
Unpacked Size
6.17 kB
Size
2.51 kB
File Count
12
NPM Version
6.14.9
Node Version
14.15.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
React hooks for make constant pointer to function/handler
1import { useConstHandler } from "use-constant-handler"; 2 3const Component = ({ onEvent, onInit }) => { 4 // pointer to onInit callback can changed, but pointor to initHandler don't change 5 const onInitHandler = useConstFunc(() => onInit()); 6 useEffect(() => { 7 onInitHandler(); 8 }, [onInitHandler]); //it will call only once becouse initHandler don`t change 9 10 11 // We do not need redraw input when onEvent callback change. 12 // New onEvent callback need only when SubComponent call onEvent. 13 // Pointer to onChange callback can changed, 14 // but pointor to onChangeHandler don't change 15 const onEventHandler = useConstHandler((e) => onEvent(e)) 16 return <SubComponent onEvent={onEventHandler}/>; 17}
1const useConstFunc = (f) => { 2 const { current } = useRef((...args) => current[FUNC_KEY]?.(...args)); 3 current[FUNC_KEY] = f; 4 return current; 5};
1const useConstHandler = (f) => { 2 const { current } = useRef((...args) => (current[FUNC_KEY] ?? f)(...args)); 3 4 useLayoutEffect(() => { 5 current[FUNC_KEY] = f; 6 }); 7 8 return current; 9};
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/9 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
20 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More