Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
storybook-controlled
Advanced tools
A simple utility for connecting controlled components to storybook actions, controls and state
A simple utility for connecting controlled components to storybook actions, tests, controls and state
const IncrementorButton = ({count, setCount}) => (
<button onClick={() => setCount(count+1)}>
{count}
</button>
)
const BasicUsage = {
decorators: [controlledDecorator("onClick", "count")],
}
See the Storybook for more examples
storybook-controlled is meant to be the go-to best practice for writing stories for controlled components in Storybook. It simplifies the process of managing state and actions, allowing developers to create interactive stories that respond to user input seamlessly.
Controlled components often take a value or set of values to display and a callback to update those values. They leave it up to implementers to implement the onChange function and update the passed values. This creates extra flexibility, but causes some issues when it comes to testing.
There are generally two approaches to writing stories for controlled components:
action()/fn()
to mock the callbackThese each have drawbacks. Custom render functions generally break at least some controls, in this case the best case is that the non-functional args are omitted, but often they just don't work. Using storybooks mocks is nice, but you don't get to see the component change in response to user action.
This package introduces a custom Decorator that streamlines the integration between args and callback mocking. By providing a simple interface, the Decorator takes the name of the callback and the state to update as arguments. When applied, it:
The strong TypeScript types prevent common errors, making it easier for developers to implement and use.
FAQs
A simple utility for connecting controlled components to storybook actions, controls and state
The npm package storybook-controlled receives a total of 262 weekly downloads. As such, storybook-controlled popularity was classified as not popular.
We found that storybook-controlled demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.