
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
The jQuery for React.
A small library with utilities and shorthands for React.
To get started, import the library as follows:
import * as $ from 'hoko';
To create your first state variable, use the $.state
function:
import * as $ from 'hoko'; // 225 B
function Component() {
const state = $.state({
count: 0,
});
return (
<div>
<h1>Count: {state.count}</h1>
<button onClick={() => state.count++}>Increment</button>
</div>
);
}
Install hoko from npm
with your package manager of your choice:
npm install hoko # npm
yarn add hoko # yarn
bun add hoko # bun
pnpm add hoko # pnpm
$.state({ ... })
Creates a local state variable inside a React component.
This allows for
managing multiple state variables inside a single hook.
const state = $.state({
count: 0,
});
$.effect(() => {
console.log(state.count);
}, [state.count]); // the state as a dependency
console.log(state.count); // 0
state.count = 1; // updating the state
Alternatively, you can use the createState
exported from hoko
.
NOTE: Unfortunately, due to properties being a setter and getter pair, the state variable is mutable, but cannot be destructured.
- let { count } = $.state({ count: 0 });
$.globals({ ... })
Creates a global state variable, which is shared between all components.
Similarly to $.state
, the state variable is mutable, but cannot be
destructured.
const useState = $.globals({
count: 0,
});
function Component() {
const state = useState();
return (
<div>
<h1>Count: {state.count}</h1>
<button onClick={() => state.count++}>Increment</button>
</div>
);
}
Alternatively, you can use the createGlobals
exported from hoko
.
$.rerender()
A function that can be used to force a re-render of a component.
const rerender = $.rerender();
rerender();
$.ref
A shorthand for React.useRef
that
passes null
as an argument by default.
$.id
A shorthand for React.useId
.
$.effect
or $.on
A shorthand for
React.useEffect
.
$.reducer
A shorthand for
React.useReducer
.
$.transition
A shorthand for
React.useTransition
.
MIT 💖
FAQs
The jQuery for React
The npm package hoko receives a total of 245 weekly downloads. As such, hoko popularity was classified as not popular.
We found that hoko demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.