When designing and implementing web interfaces to ensure they are usable by everyone.
日本語の概要は準備中です。原文の説明を表示しています。
When deciding where and how to store data in a modern web application.
インストール方法を見るインストールする前に、エージェントに与えられる指示の中身を確認できます。
Applications suffer from bugs and performance issues when state lives in the wrong place. This skill guides teams to categorize state by its nature (UI, server, URL, global) and store it appropriately, eliminating duplication, excessive re-renders, and synchronization bugs.
useState onlyconst [val, setVal] = useState(props.val) (causes sync bugs)useStateuseState❌ Anti-pattern (Wrong state locations, duplication, mirroring):
// Redux store has everything including UI state
const store = {
filters: { search: '', sort: 'name' }, // WRONG: belongs in URL
users: [...], // OK: server data
isModalOpen: false, // WRONG: UI-only state
theme: 'dark' // OK: truly global
};
// Component mirrors props and stores server data locally
const UserList = ({ searchQuery }) => {
const [search, setSearch] = useState(searchQuery); // ANTI-PATTERN: mirrors props
const [users, setUsers] = useState([]); // ANTI-PATTERN: manual server sync
useEffect(() => {
fetch(`/api/users?q=${search}`)
.then(res => res.json())
.then(data => setUsers(data)); // Manual sync to local state
}, [search]);
return <div>{users.map(u => <p>{u.name}</p>)}</div>;
};
✅ Correct pattern (Proper state separation):
const UserList = () => {
// 1. URL drives state (filters/search)
const [searchParams, setSearchParams] = useSearchParams();
const search = searchParams.get('q') || '';
// 2. Server data via React Query (cached, not Redux)
const { data: users } = useQuery({
queryKey: ['users', search],
queryFn: () => fetch(`/api/users?q=${search}`).then(r => r.json())
});
// 3. UI-only state stays local
const [isModalOpen, setIsModalOpen] = useState(false);
// 4. Global state from Context/Redux
const { theme } = useContext(ThemeContext);
return (
<div>
<input
value={search}
onChange={(e) => setSearchParams({ q: e.target.value })}
/>
<button onClick={() => setIsModalOpen(true)}>Add User</button>
{users?.map(u => <p>{u.name}</p>)}
</div>
);
};
まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
When designing and implementing web interfaces to ensure they are usable by everyone.
日本語の概要は準備中です。原文の説明を表示しています。
When creating or extending an HTTP API for client consumption.
日本語の概要は準備中です。原文の説明を表示しています。
When improving read performance and reducing database load.
日本語の概要は準備中です。原文の説明を表示しています。
When configuring automated build, test, and deployment workflows for a repository.
日本語の概要は準備中です。原文の説明を表示しています。
When asynchronously reviewing peer code before merging into the main branch.
日本語の概要は準備中です。原文の説明を表示しています。
When addressing slow application endpoints, high database CPU usage, or standardizing data access patterns.
日本語の概要は準備中です。原文の説明を表示しています。