
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-thunk
Advanced tools
Define React functional stateless components as thunks
npm i --save react-thunk
Instead of doing the following, and setting a new change listener on each render:
function NameField(props) {
const { name, setName } = props;
return <input type="text" value={ name } onChange={ (evt) => setName(evt.target.value) } />;
}
Do the following, and only define your change listener once:
function NameField(initialProps) {
const { setName } = initialProps;
const changeHandler = (evt) => setName(evt.target.value);
return (props) => {
const { name } = props;
return <input type="text" value={ name } onChange={ changeHandler } />;
};
}
It creates a class for you: https://github.com/troch/react-thunk/blob/master/modules/index.js. That is all the source code.
thunk(component: Function[, pure: Boolean])
Since a thunk creates a class, it gives you the opportunity to have pure components (set second argument to true).
import React from 'react';
import thunk from 'react-thunk';
function NameField() {
/* ... */
}
export default thunk(NameField);
FAQs
Functional stateless React components returning thunks
We found that react-thunk 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.