Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
create-hook-context
Advanced tools
A more powerful version of React.createContext
. Accepts a hook that takes in props for a provider, and then returned value of the hook, is the value provided to the context's consumers.
Signature:
import createContext from 'create-hook-context';
const [ThemeProvider, useTheme, withThemeProvider, ThemeContext] = createContext(
({ theme }) => theme, // hook that provides values for context given input
{}, // defaultValue for context
"Theme" // displayName for Context
)
const Consumer = () => {
const val = useTheme();
return <pre>{JSON.stringify(val)}</pre>;
};
const App = () => {
return (
<ThemeProvider theme={{ a: 1 }}>
<Consumer />
</ThemeProvider>
);
};
/* or can use withThemeProvider to wrap components */
const App = withThemeProvider({ theme: { a: 1 } }, () => {
const val = useTheme();
return <pre>{JSON.stringify(val)}</pre>;
});
FAQs
Create context using a hook for providers
We found that create-hook-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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.