react hoc functional component example

Example 1: functional component react

function Welcome(props) {
  return 

Hello, {props.name}

; } function App() { return (
); } ReactDOM.render( , document.getElementById('root') );

Example 2: react functional components

const component = () => {
console.log("This is a functional Component");
}

Example 3: high level components react

import React, { useState } from 'react';

class WelcomeName extends React.Component {
  render() {
    return 

Hello, {this.props.name}

} } function HighHookWelcome() { const [name ,setName] = useState("Default Name Here"); return( ); } // Note: Didn't need to use state for a static value. // Minimal example, just to illustrate passing state/props. // setName is a function to change the name value.

Tags:

Misc Example