
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@nodecg/react-hooks
Advanced tools
This package is a collection custom hooks of React Hooks for NodeCG API.
🚨 This package is in alpha state. But feel free to try out and file an issue for suggestion/bugs!
npm install @nodecg/react-hooks
# or
yarn add @nodecg/react-hooks
# or
pnpm add @nodecg/react-hooks
(This section comes from when React hooks was just introduced as an alpha feature, but is still useful to keep as an introduction.)
The React Hooks are a new way of sharing code between components, introduced in version 16.8.
Please read the documentation of React Hooks thoroughly before using them.
It also helps to learn the background mechanism of React Hooks. React hooks: not magic, just arrays
Use eslint-plugin-react-hooks in your project. It is 100% smarter than you to detect violation of the Rules of Hooks.
useReplicant
import { useReplicant } from "@nodecg/react-hooks";
// This component will re-render when the `counter replicant value changes
export function RunnerName() {
const [count, setCount] = useReplicant("counter");
return (
<div>
<div>{count}</div>
<button onClick={() => setCount(count + 1)} />
</div>
);
}
useListenFor
listenFor
, and unlistens on unmount.import { useListenFor } from "@nodecg/react-hooks";
// Shows modal for 1 second when NodeCG receives 'errorHappened' message from the server
export function AlertOnMessage() {
const [showAlert, setShowAlert] = useState(false);
useListenFor("errorHappened", () => {
setShowAlert(true);
});
useEffect(() => {
if (!showAlert) {
return;
}
// Disappear alert 1 second after
const timer = setTimeout(() => {
setShowAlert(false);
}, 1000);
// Make sure to return cleanup function
return () => {
clearTimeout(timer);
};
}, [showAlert]);
return <Modal show={showAlert} />;
}
MIT © Keiichiro Amemiya (Hoishin)
FAQs
Custom React Hooks for NodeCG
We found that @nodecg/react-hooks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.