
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
@reactions/component
Advanced tools
Declarative version of React.Component.
Because sometimes you want a lifecycle or some state but don't want to create a new component. Also, this stuff is composable as heck.
npm install @reactions/component
# or
yarn add @reactions/component
And then import it:
// using es modules
import Component from '@reactions/component';
// common.js
const Component = require('@reactions/component');
// AMD
// I've forgotten but it should work.
Or use script tags and globals.
<script src="https://unpkg.com/@reactions/component"></script>
And then grab it off the global like so:
const Component = ReactComponentComponent;
Let's say you want some async data but don't want to make a whole new component just for the lifecycles to get it:
// import Component from '@reactions/component'
const Component = ReactComponentComponent;
ReactDOM.render(
<div>
<h2>Let's get some gists!</h2>
<Component
initialState={{ gists: null }}
didMount={({ setState }) => {
fetch("https://api.github.com/gists")
.then(res => res.json())
.then(gists => setState({ gists }));
}}
>
{({ state }) =>
state.gists ? (
<ul>
{state.gists.map(gist => (
<li key={gist.id}>{gist.description}</li>
))}
</ul>
) : (
<div>Loading...</div>
)
}
</Component>
</div>,
DOM_NODE
);
Or maybe you need a little bit of state but an entire component seems a bit heavy:
// import Component from '@reactions/component'
const Component = ReactComponentComponent;
ReactDOM.render(
<Component initialState={{ count: 0 }}>
{({ setState, state }) => (
<div>
<h2>Every app needs a counter!</h2>
<button
onClick={() =>
setState(state => ({ count: state.count - 1 }))
}
>
-
</button>
<span> {state.count} </span>
<button
onClick={() =>
setState(state => ({ count: state.count + 1 }))
}
>
+
</button>
</div>
)}
</Component>,
DOM_NODE
);
You know all of these already:
didMount({ state, setState, props, forceUpdate })
shouldUpdate({ state, props, nextProps, nextState })
didUpdate({ state, setState, props, forceUpdate, prevProps, prevState })
willUnmount({ state, props })
children({ state, setState, props, forceUpdate })
render({ state, setState, props, forceUpdate })
Released under MIT license.
Copyright © 2017-present Ryan Florence
FAQs
Declarative Version of React.Component
We found that @reactions/component 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.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.