Loading...
Loading...
Use when writing, fixing, editing, or refactoring React components, JSX, props, discriminated union props, conditional rendering, loading/error/empty states, render purity, component boundaries, or component composition.
npx skill4agent add gosukiwi/clean-code-react clean-react-componentsButtonTextFieldInvoiceSummaryShippingAddressStep// Bad - call site meaning is unclear
<UserCard user={user} true false "compact" />
// Good - one named concept
<UserCard user={user} variant="compact" showActions={false} />// Bad - caller can pass contradictory props
type BannerProps = {
isLoading?: boolean;
error?: Error;
message?: string;
};
// Good - each mode owns the props it needs
type BannerProps =
| { status: "loading" }
| { status: "error"; error: Error }
| { status: "ready"; message: string };// Bad - one component owns unrelated modes
<Panel isModal isDismissible hasFooter />
// Good - structure communicates behavior
<Modal onDismiss={closeModal}>
<PanelFooter actions={actions} />
</Modal>if (status === "loading") {
return <Spinner />;
}
if (status === "error") {
return <ErrorMessage error={error} />;
}
return <OrderDetails order={order} />;useEffect// Bad - names the element, not the intent
function handleButtonClick() {
setItems(items.filter((item) => item.id !== id));
}
// Good - names what the user did
function handleRemoveItem(id: string) {
setItems((items) => items.filter((item) => item.id !== id));
}// Bad - mutation path is buried in JSX
<button onClick={() => {
setLoading(true);
setError(null);
submitOrder(cart);
}}>
Place Order
</button>
// Good - intent is named, path is visible
<button onClick={handlePlaceOrder}>Place Order</button>components/className