React - Function Component

About

This page is about the writing of component with the functional syntax

Syntax

function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}

Example

  • A UD DOM component defining the Welcome tag
function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}
  • A React element using this DOM tag
const element = <Welcome name="Sarah Connor" />;
  • Rendering
ReactDOM.render(
  element,
  document.getElementById('root')
);
  • The standard mandatory “root” DOM node (placeholder for React DOM manipulation)
<div id="root"></div>
  • Output:

Management

Loop

Update


Powered by ComboStrap