Composition vs Inheritance – React
reactjs.org · 874 words · saved by 1 readers
A JavaScript library for building user interfaces
These docs are old and won’t be updated. Go to react.dev for the new React docs. React has a powerful composition model, and we recommend using composition instead of inheritance to reuse code between components. In this section, we will consider a few problems where developers new to React often reach for inheritance, and show how we can solve them with composition. Containment Some components don’t know their children ahead of time. This is especially common for components like Sidebar or Dialog that represent generic “boxes”. We recommend that such components use the special children prop t
saved by
related reading
- Forms – Reactreactjs.org
- Build your own Reactpomb.us
- You Might Not Need an Effect – Reactreact.dev
- Why React Re-Renders • Josh W. Comeaujoshwcomeau.com
- How Props Work in React – A Beginner's Guidefreecodecamp.org
- Blogged Answers: A (Mostly) Complete Guide to React Rendering Behavior · Mark's Dev Blogblog.isquaredsoftware.com
- Tao of React - Software Design, Architecture & Best Practices | Alex Kondovalexkondov.com
- React handbookdevouringdetails.com
- Implementing React from scratchrob.directory
- Tutorial: Tic-Tac-Toe – Reactreactjs.org
- When does React re-render components? | Felix Gerschaufelixgerschau.com
- Container/Presentational Patternpatterns.dev