When should I lift state up in React?
When two or more components need the same state, lift it to their common parent. But do not lift everything to the top of the tree; lift only what is genuinely shared to keep components focused.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in React Component Composition Best Practices for Clean Code
Because composition scales better. Instead of extending base components and creating rigid hierarchies, you build small focused components and combine them. This is more flexible and easier to change as the app grows.
The children prop lets you pass nested elements into a component. A Card component that renders its children is reusable for any content, instead of being hardcoded to specific elements.
There is no fixed number, but a component with around fifteen props is usually doing too much. If you are passing many props, consider splitting the component or grouping related props into an object.
Still have questions?
Browse all our FAQs or reach out to our support team
