
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Create custom useState hook that can be used inside multiple components and will share state across all of them (and will update all of them if state is changed)
import { createSharedStateHook } from 'use-state-shared';
// create custom `useState` hook and set default value only once.
export const customUseState = createSharedStateHook(0);
// later import `customUseState` anywhere in the app
// use the same way as `useState` inside multiple different components.
// `currentState` will be always synced between all of them.
// changing it in any component will cause change in every component using it with updated value
const [currentState, setState] = customUseState();
import { createSharedStateHook } from 'use-state-shared';
// create custom state hook with some initial value
// such hook can be created in some separated file and imported to many different components
const useGlobalCount = createSharedStateHook(0);
const useAnotherGlobalCount = createSharedStateHook(0);
function ComponentA() {
const [globalCount, setGlobalCount] = useGlobalCount();
const [anotherGlobalCount] = useAnotherGlobalCount();
return (
<div>
I'm first component and count is {globalCount}. 2nd count is{' '}
{anotherGlobalCount}.
<button onClick={() => setGlobalCount(globalCount + 1)}>Increase</button>
</div>
);
}
function ComponentB() {
const [globalCount, setGlobalCount] = useGlobalCount();
const [anotherGlobalCount, setAnotherGlobalCount] = useAnotherGlobalCount();
return (
<div>
I'm second component. Count is {globalCount}. This count will always be
synced with ComponentA count.
<button onClick={() => setGlobalCount(globalCount - 1)}>Decrease</button>
<button onClick={() => setAnotherGlobalCount(anotherGlobalCount + 1)}>
Increase 2nd count
</button>
</div>
);
}
FAQs
[demo](https://pie6k.github.io/use-state-shared/)
The npm package hooksy receives a total of 11 weekly downloads. As such, hooksy popularity was classified as not popular.
We found that hooksy 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.