Lexicon
⌘K
Explore
ExploreGuidesNotes
WriteMy Library
Sign in
Browse

Networking

  • OSI Model
  • TCP vs UDP
  • TCP/IP Model
  • Layer 2 & Layer 3 Networking

Programming

  • Start Here — How to Solve a Problem
  • From if/else to DSA — The Whole Path
  • Problem Solving
  • DSA Practice — Learn by Solving
  • C Programming
  • Python

Bug Bounty

  • Only Bug Bounty Checklist You'll Ever Need!!!
  • Only Bug Bounty Checklist You'll Ever Need!!! V2

My Notes

  • Python Conditional Statements - The Complete Breakdown
  • Python Data Types - The Complete Breakdown
  • Python Dictionaries - The Complete Breakdown
  • Python Exception Handling - The Complete Breakdown
  • Python Functions - The Complete Breakdown
  • Python Lists vs Arrays — The Real Story
  • Python Loops - The Complete Breakdown
  • Python OOP - The Complete Breakdown
  • The f Thing in Python - f-strings

Python

  • Python String Manipulation Functions - Full Reference
New noteSuggest a guide

Lexicon

a personal knowledge base

React

React component design principles

scorpionxdevUpdated 5/5/2026 · 2 min read · 0 views
PDFHistory

A handful of principles that keep React components easy to change. None of them are rules, but ignoring all of them tends to produce components that are painful to touch six months later.

Keep components small and focused

A component should do one thing. If you struggle to name it, or its render function scrolls off the screen, it is probably two components.

Separate presentation from logic

Push data fetching and business rules up into hooks or container components, and keep leaf components dumb. A dumb component that only takes props is trivial to test and reuse.

function useUser(id: string) {
  const [user, setUser] = useState<User | null>(null);
  useEffect(() => {
    let active = true;
    getUser(id).then((u) => active && setUser(u));
    return () => { active = false; };
  }, [id]);
  return user;
}

function UserCard({ user }: { user: User }) {
  return <div className='card'>{user.name}</div>;
}

Lift state only as high as it needs to go

Shared state belongs at the closest common ancestor, not at the top of the app. Global state for everything makes every change ripple.

Props are a contract

  • Keep the prop list short. Many props is a smell that the component does too much.
  • Prefer specific props over a giant config object.
  • Use children for composition instead of passing render logic through props.

Derive, do not duplicate

If a value can be computed from existing state or props, compute it during render instead of storing it in another piece of state. Duplicated state drifts out of sync.

// Do not store this in state, just derive it
const completed = todos.filter((t) => t.done).length;

Keys must be stable

List keys should be stable identifiers, not array indexes. Index keys cause subtle bugs when the list reorders or items are inserted.

Reading progress0%
scorpionxdev@scorpionxdev

Effects are for synchronizing with the outside world

Reach for useEffect to sync with something external such as the network, a subscription, or the DOM. If you are only transforming data for rendering, you probably do not need an effect at all.

0 comments

Sign in to join the discussion.