
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-closure-hooks
Advanced tools
reexport react hooks, and add useEvent. They are useful for solving the closure problem in react hooks.
npm install --save react-closure-hooks
or
yarn add react-closure-hooks
// Test
import React from 'react';
import { Search } from 'antd';
import { useState, useEvent } from 'react-closure-hooks';
import API from '@/request';
const Test = () => {
const [searchKey, setSearchKey] = useState('');
const [result, setResult] = useState('');
const doQuery = useEvent(async () => {
const result = await API.query({
searchKey
});
setResult(result);
});
const doSearch = useEvent(async (e) => {
await setSearchKey(e.target.value);
doQuery();
});
return (
<div>
<Search
value={searchKey}
onSearch={doSearch}
><br />
<div>{result}</div>
</div>
);
};
export default Test;
or use useStateWithPromise
// Test
import React, { useState } from 'react';
import { Search } from 'antd';
import { useStateWithPromise, useEvent } from 'react-closure-hooks';
import API from '@/request';
const Test = () => {
const [searchKey, setSearchKey] = useStateWithPromise('');
const [result, setResult] = useState('');
const doQuery = useEvent(async () => {
const result = await API.query({
searchKey
});
setResult(result);
});
const doSearch = useEvent(async (e) => {
await setSearchKey(e.target.value);
doQuery();
});
return (
<div>
<Search
value={searchKey}
onSearch={doSearch}
><br />
<div>{result}</div>
</div>
);
};
export default Test;
FAQs
some hooks for resolve closure problem in react hooks
We found that react-closure-hooks demonstrated a not healthy version release cadence and project activity because the last version was released 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.