
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
simply-context
Advanced tools
A simple and easy-to-use context manager for React applications.
To install Simply Context in your project, run the following command:
npm install simply-context
First, import the SimplyProvider component and the SimplyUseData hook from the simply-context package:
import { SimplyProvider, SimplyUseData } from "simply-context";
Then, wrap your root component with the simplyProvider component and pass in any initial state you would like to use:
const App = () => {
return (
<SimplyProvider initialState={{ username: "" }}>
{/* your app components here */}
</SimplyProvider>
);
};
Next, you can use the SimplyUseData hook anywhere in your app to access and modify the context data:
const LoginForm = () => {
const [username, setUsername] = SimplyUseData("username");
const usernameRef = React.useRef <HTMLInputElement>(null);
const handleLogin = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
// do something with the username
if (usernameRef.current) {
let name = usernameRef.current.value;
setUsername(name);
}
};
return (
<form onSubmit={handleLogin}>
<input name="username" type="text" value={username} ref={usernameRef} />
<button type="submit">Login</button>
</form>
);
};
The SimplyProvider component is a higher-order component that provides the context data and setter functions to its children components.
initialState (optional): an object that represents the initial state of the context data.The SimplyUseData hook is a hook that allows you to access and modify the context data from anywhere in your app.
key: a string that represents the key of the context data you would like to access.An array containing the value of the context data at the given key and a function that allows you to modify the context data.
For more examples and use cases of Simply Context, check out the example folder in this repository.
Simply Context is released under the MIT license. See LICENSE for details.
Contributions are welcome! Please see CONTRIBUTING for details.
Simply Context is maintained by Mathieu Piton.
FAQs
Simplify the React API context
We found that simply-context 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
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.