React (JavaScript library): Difference between revisions

 
Line 1: Line 1:


==Components==
==Components==
React has two types of components: class components (those which extend React.Component) and function components.
Components are reusable pieces of jsx which depend on some input properties and get rerendered whenever those properties change.
Function components are lighter weight and should be preferred for new code.
 
React has two types of components: function components and class components (those which extend React.Component).
Historically, class components were used for components with state and function components were stateless.
Today, function components can also have state using hooks and should be preferred for new code.


===Function components===
===Function components===