
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
react-dynamic-context
Advanced tools
This Documentation is currently under construction
Type-safe dynamic context with only a few lines of code.
yarn add react-dynamic-context
# or
npm i react-dynamic-context
import * as React from 'react';
import { createDynamicContext, DynamicProvider } from 'react-dynamic-context';
const SomeContext = createDynamicContext<{ foo: string }>({
foo: 'default-value'
});
const App = () => (
<DynamicProvider>
<SomeContext.Consumer>
{ctx => (
<input
onChange={e => ctx.foo.setValue(e.target.value)}
value={ctx.foo.value}
/>
)}
</SomeContext.Consumer>
</DynamicProvider>
);
live-examples on codesandbox:
The interface must not contain any optional values:
import { createDynamicContext } from 'react-dynamic-context';
// ERROR: Type '{ foo?: string | undefined; }' does not satisfy the constraint 'Required<{ foo?: string | undefined; }>'.
createDynamicContext<{ foo?: string }>({});
// CORRECT:
createDynamicContext<{ foo: string | undefined }>({ foo: undefined });
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { createDynamicContext, DynamicProvider } from 'react-dynamic-context';
const SomeContext = createDynamicContext<{ foo: string; bar: string }>({
foo: 'current-foo-value',
bar: 'current-bar-value'
});
const OtherContext = createDynamicContext<{ baz: string }>({
baz: 'current-baz-value'
});
const Comp = () => (
<div>
<SomeContext.Consumer>
{ctx => (
<input
onChange={e => ctx.bar.setValue(e.target.value)}
value={ctx.bar.value}
/>
)}
</SomeContext.Consumer>
<OtherContext.Consumer>
{ctx => (
<input onChange={ctx.baz.handleInputChange} value={ctx.baz.value} />
)}
</OtherContext.Consumer>
<SomeContext.ValuesConsumer>
{values => (
<div>
<p>other: {values.foo}</p>
<p>language: {values.bar}</p>
</div>
)}
</SomeContext.ValuesConsumer>
</div>
);
const App = () => (
<DynamicProvider>
<Comp />
</DynamicProvider>
);
ReactDOM.render(<App />, document.getElementById('root') as HTMLElement);
FAQs
Type-safe dynamic context with only a few lines of code.
We found that react-dynamic-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
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.