Components
Class Components
Functional Components
React functional components are like JavaScript functions.
Rendering a Component
What's happening here is :
We call
ReactDOM.render()
with the<Welcome name="World" />
element.React calls the
Welcome
component with{name: 'World'}
as the props.Our
Welcome
component returns a<h1>Hello, World</h1>
element as the result.React DOM efficiently updates the DOM to match
<h1>Hello, World</h1>
.
Composing Components
Components can refer other components in their output.
Props are read only.
A function or class which never modify its own props are called "pure" because they don't change their input and produce same result every time with the same inputs.
props get passed to the component (similar to function parameters) whereas state is managed within the component (similar to variables declared within a function).
Last updated
Was this helpful?