Create a Component
Components are JavaScript functions or classes that accept parameters, called props, and return a description of the UI based on those parameters. In this way, you can render the HTML elements and the application data in one go, without writing additional code to update values inside the HTML. When the data changes, you pass updated props to the component. React takes care of re-rendering the page.
A component can be any JavaScript function that takes an object as a parameter and returns an element created with React.createElement. Since components are JavaScript functions, you can transform the data with the full power of JavaScript before creating the output. Our first component will be a function that takes two numbers and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access