
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
react-shared-workspace
Advanced tools
Share state across siblings!
yarn add react react-shared-workspace
import React from "react";
import ReactDOM from "react-dom";
import { Workspaces, createWorkspace } from "react-shared-workspace";
// provide initial state to workspace
const Workspace = createWorkspace({
count: 0
});
function Counter() {
return <Workspace>{({ state }) => <span>{state.count}</span>}</Workspace>;
}
function IncrementButton() {
return (
<Workspace>
{({ setState }) => (
<button
onClick={() => {
setState(state => ({
count: state.count + 1
}));
}}
>
Up
</button>
)}
</Workspace>
);
}
function DecrementButton() {
return (
<Workspace>
{({ setState }) => (
<button
onClick={() => {
setState(state => ({
count: state.count - 1
}));
}}
>
Down
</button>
)}
</Workspace>
);
}
function App() {
return (
<Workspaces>
<Counter />
<IncrementButton />
<DecrementButton />
</Workspaces>
);
}
ReactDOM.render(<App />, document.getElementById("root"));
The Workspaces component stores all the state so put it high up in the react tree. createWorkspace returns a Workspace component whose state is linked across all of it's instances. When all instances of Workspace unmount, the state for that workspace is cleaned up.
FAQs
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
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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.