
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
usemergedstate
Advanced tools
A replica of the React State Hook with the power of merging states.
If you already know about React Hooks, you can skip this section and if not, continue reading.
The best way I think you can actually learn about Hooks is to watch this video(from react-conf) where Sophie Alpert and Dan Abramov explained in details what hooks are and why they exist. However, I would try and explain a bit here.
React State Hook is one of the many hooks that exist as feature proposal in React v16.7.0-alpha. Hooks are a new feature proposal that lets you use state and other React features without writing a class. With React State Hook(useState), you can make use of state in functional components(without writing a class).
This is a link to the documentation on Hooks.
The useState hook exposes APIs that you can easily use to read and update the state created. However, the API for updating the state is actually going to replace the previous state with the new state.
Example:
const [userInfo, setUserInfo] = useState({ name: 'Dan', age: 26 });
// userInfo => { name: 'Dan', age: 26 }
setUserInfo({age: 27});
// userInfo => {age: 27}
The replacing behavior of useState is very well argued to be a befitting one on the State Hook documentation, however, I strongly believe that there are a lot of valid scenarios where developers would want to merge stuff to the state(without going the reducer way) as opposed to replacing the state.
If you are one of the folks that get limited with the replacing behavior of useState, then useMergedState is just for you.
useMergedState is Here to Help :sparkles:useMergedState makes it possible to merge states(when they are objects).
If the previous state and the new state are both objects, useMergedState is going to merge the states(just like this.setState) but if they are not, it is simply going to replace the previous state with the new one(the default behavior of useState).
- You need(at minimum)
react@16.7.0-alpha.0to use this package.
npm i usemergedstate
Requiring the module:
const useMergedState = require('usemergedstate');
Merging State:
...
const [userInfo, setUserInfo] = useMergedState({ name: 'Dan', age: 26 });
// userInfo => { name: 'Dan', age: 26 }
setUserInfo({age: 27});
// userInfo => { name: 'Dan', age: 27 }
...
Roll back to default behavior:
...
const [name, setName] = useMergedState('Dan');
// name => 'Dan'
setName('Abramov');
// name => 'Abramov'
...
FAQs
A replica of the React State Hook with the power of merging states
We found that usemergedstate 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.