mobx
БесплатноБез исполняемых скриптовНе проверенMobX is a state management library for JavaScript and React that makes state observable, so computed values and components update automatically when it…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
MobX — Reactive State Management
Overview
MobX is a simple and scalable state management library based on transparent reactive programming. State is made observable, derived values are computed from it, actions mutate it, and reactions run side effects — the UI updates automatically when the state it read changes, without manual subscriptions. Stores can be classes or plain objects.
Current major version: MobX 7 (July 2026) with mobx-react-lite 5 for function components and mobx-react 10 for class components. MobX 7 is a cleanup release: Proxy-only, Stage 3 decorators only, and several namespaced APIs became named exports (see "MobX 7 changes" below).
Instructions
Installation
npm install mobx mobx-react-lite
Use mobx-react instead of mobx-react-lite only when class components or the @observer class decorator are needed. With TypeScript, set "useDefineForClassFields": true in tsconfig.json; without spec-compliant class fields, a field declared without an initial value (user?: User;) cannot be made observable.
Observable Store
// stores/todo-store.ts
import { makeAutoObservable, runInAction } from "mobx";
export interface Todo { id: string; text: string; done: boolean }
export class TodoStore {
todos: Todo[] = [];
filter: "all" | "active" | "done" = "all";
isLoading = false;
constructor() {
// Infers observables, computeds (getters), actions (methods), flows (generators).
// autoBind lets methods be passed around as callbacks: onClick={store.addTodo}
makeAutoObservable(this, {}, { autoBind: true });
}
// Computed (cached, recalculated only when dependencies change)
get filteredTodos() {
switch (this.filter) {
case "active": return this.todos.filter(t => !t.done);
case "done": return this.todos.filter(t => t.done);
default: return this.todos;
}
}
get remaining() {
return this.todos.filter(t => !t.done).length;
}
// Actions (state mutations)
addTodo(text: string) {
this.todos.push({ id: crypto.randomUUID(), text, done: false });
}
toggleTodo(id: string) {
const todo = this.todos.find(t => t.id === id);
if (todo) todo.done = !todo.done; // Direct mutation — MobX tracks it
}
removeTodo(id: string) {
this.todos = this.todos.filter(t => t.id !== id);
}
// Async action: code after an await is no longer inside the action
async fetchTodos() {
this.isLoading = true;
try {
const response = await fetch("/api/todos");
const data: Todo[] = await response.json();
runInAction(() => { this.todos = data; });
} finally {
runInAction(() => { this.isLoading = false; });
}
}
// Same thing as a flow: a generator needs no runInAction after each yield
*syncTodos(): Generator<Promise<unknown>, number, any> {
this.isLoading = true;
try {
const response = yield fetch("/api/todos");
this.todos = yield response.json();
return this.todos.length;
} finally {
this.isLoading = false;
}
}
}
Call a flow like a normal method; in TypeScript wrap it to get a typed promise: const count = await flowResult(store.syncTodos()).
Observer Components
import { createContext, useContext } from "react";
import { observer, useLocalObservable } from "mobx-react-lite";
import { TodoStore } from "./stores/todo-store";
const StoreContext = createContext<TodoStore | null>(null);
const useStore = () => {
const store = useContext(StoreContext);
if (!store) throw new Error("StoreContext.Provider is missing");
return store;
};
// observer tracks which observables the render read and re-renders only for those
const TodoList = observer(() => {
const store = useStore();
if (store.isLoading) return <p>Loading…</p>;
return (
<div>
<p>{store.remaining} remaining</p>
<ul>
{store.filteredTodos.map(t => (
<li key={t.id} onClick={() => store.toggleTodo(t.id)}
style={{ textDecoration: t.done ? "line-through" : "none" }}>
{t.text}
</li>
))}
</ul>
</div>
);
});
// Component-local observable state
const Counter = observer(() => {
const state = useLocalObservable(() => ({ count: 0, increment() { this.count++; } }));
return <button onClick={state.increment}>Clicked {state.count} times</button>;
});
export const App = ({ store }: { store: TodoStore }) => (
<StoreContext.Provider value={store}><TodoList /><Counter /></StoreContext.Provider>
);
Reactions
import { autorun, reaction, when } from "mobx";
// reaction: runs the effect when the tracked expression changes (not on creation)
const dispose = reaction(
() => store.remaining,
(remaining, previous) => { document.title = `${remaining} todos left (was ${previous})`; },
);
// autorun: runs once immediately, then whenever anything it read changes
const stopSaving = autorun(() => {
localStorage.setItem("todos", JS
Установить mobx в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл mobx?
MobX is a state management library for JavaScript and React that makes state observable, so computed values and components update automatically when it changes. Use when a user asks to add MobX to a React app, create a store with makeAutoObservable, wrap components in observer, write computed values, actions, reactions or flow, fix a MobX component that does not re-render, or migrate from MobX 6 to MobX 7.
Как установить скилл mobx?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mobx запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic