Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React: Composite components vs DOM components

Tags:

reactjs

What is the difference between a "composite component" and a "DOM component" in react?

The official docs contrasts the two terms to each other in a few places, but never really explains them. Eg: https://facebook.github.io/react/docs/component-specs.html https://facebook.github.io/react/docs/working-with-the-browser.html

From react 0.14 a few of test utils methods, like findRenderedDOMComponentWithClass no longer takes "DOM components".

like image 243
swelet Avatar asked Oct 13 '15 07:10

swelet


People also ask

What is a composite component in React?

What are compound components in React? Compound components are a pattern in which components are used together such that they share an implicit state that lets them communicate with each other in the background.

What are some advantages of React component composition over inheritance?

Reason for composition over inheritance children, we can separate code in the separated places. We do not need to go very deep in the components and create many ifs. The next important thing. With composition, we follow the “everything is component” model designed by React.

What are DOM components in React?

What is the DOM? The DOM (Document Object Model) represents the web page as a tree structure. Any piece of HTML that we write is added as a node, to this tree. With JavaScript, we can access any of these nodes (HTML elements) and update their styles, attributes, and so on.

What is the difference between React component and component?

React components are independent and reusable code. They are the building blocks of any React application. Components serve the same purpose as JavaScript functions, but work individually to return JSX code as elements for our UI.


1 Answers

It is clearly defined in the test-utils page. So DOM component is really a plain div or a span. Unlike a CompositeComponent that can be a div, but created but by the React.createClass().

like image 71
Ivan Aranibar Avatar answered Nov 15 '22 04:11

Ivan Aranibar