Function Component

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript) > React > Function Component

1 - About

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

Advertising

3 - Syntax

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

4 - 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:

5 - Management

5.1 - Loop

5.2 - Update

Advertising
web/javascript/react/function/function.txt · Last modified: 2019/06/21 15:02 by gerardnico