
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
ctx-provider
Advanced tools
React hooks and context utils
npm install --save ctx-provider
# or
yarn add ctx-provider
Create a context.
// src/context/count.js
import { useState } from 'react'
import createStore from 'ctx-provider'
const useCount = () => {
const [count, setCount] = useState(0)
const inc = () => setCount(count + 1)
const dec = () => setCount(count - 1)
return { count, inc, dec }
}
export const { ctx, Provider } = createStore(useCount)
Apply the provider to the app.
// src/App.jsx
import React from 'react'
import { Provider as CountProvider } from './context/count'
const App = () => (
<Provider>
<Counter />
</Provider>
)
Use the context from any component.
// src/components/Counter.jsx
import React, { useContext } from 'react'
import { ctx as countContext } from './context/count'
const Counter = () => {
const { count, inc, dec } = useContext(countContext)
return (
<div>
Count: {count}
<button onClick={() => inc()}>Increment</button>
<button onClick={() => dec()}>Decrement</button>
</div>
)
}
createStore(hook) => { ctx, Provider }
Creates a context and provider component.
const { ctx, Provider, useProvider } = createStore(useHook)
CombinedProviders
Combined multiple providers.
Prop providers
is an array.
Each item can be a provider or an object containing provider
and args
.
args
is passed into the first parameter of the hook.
<CombinedProviders
providers={[
ProviderOne,
ProviderTwo,
{
provider: ProviderThree,
args: 'initial value',
},
]}
>
/* ... */
</CombinedProviders>
Developed by Acidic9.
FAQs
React hooks and context utils
We found that ctx-provider 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.