
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A lightweight Entity Component System (ECS) implementation for React applications. This architecture allows React components to serve purely as renderers, while all state management and business logic is handled by the ECS pattern.
This provides a type-safe and scalable way to manage complex state and behavior, particularly useful for any React application that benefits from decoupled state and rendering logic.
npm install ecs-react
# or
yarn add ecs-react
Unlike traditional state management solutions like Redux or MobX, which organize state around a global store or observable objects, ecs-react takes a fundamentally different approach:
ecs-react implements the Entity Component System (ECS) pattern, which consists of:
👉 Complete example can be found here: examples/ecs-react-example
First, define your Component and Signal schemas:
import { ComponentSchema, SignalSchema } from "ecs-react";
// Define all your Component types
type MyComponents = ComponentSchema<{
counter: { count: number };
label: string;
}>;
// Define all possible Signal types
type MySignals = SignalSchema<"click" | "hover">;
Create a typed instance of the ECS:
import { ECS } from "ecs-react";
const ecs = new ECS<MyComponents, MySignals>();
Entities are created and managed through the ECS instance:
// Create a new entity
const counterEntity = ecs.createEntity();
// Add components to the entity
counterEntity.addComponent("counter", { count: 0 });
counterEntity.addComponent("lastUpdatedAt", { count: Date.now() });
Systems define behavior that operates on entities when specific signals are received:
ecs.createSystem({
name: "counterSystem",
signals: ["click"],
fn: ({ entity }) => {
entity.updateComponent("counter", prevValue => ({
count: prevValue.count + 1,
}));
},
});
The above system will run when the click signal is received.
React components can interact with entities using the provided hooks:
import { useComponent, WithEntityProps } from "ecs-react";
// Button that executes the click signal on the counter entity
const Button: React.FC<WithEntityProps<MyComponents>> = ({ entity }) => {
const onClick = () => ecs.signal("click", entity);
return <button onClick={onClick}>Click</button>;
};
// Display component that shows the counter entity
const Display: React.FC<WithEntityProps<MyComponents>> = ({ entity }) => {
// internally subscribes to updates on the counter component of the entity
const counter = useComponent(entity, "counter");
return <span>{counter?.count}</span>;
};
Post any issues and suggestions on the GitHub issues page. To contribute, fork the project and then create a pull request back to main.
FAQs
A lightweight ECS framework for React
We found that ecs-react demonstrated a healthy version release cadence and project activity because the last version was released less than 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.