react abstract component code example

Example: high level components react

import React, { useState } from 'react';

class WelcomeName extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>
  }
}

function HighHookWelcome() {
  const [name ,setName] = useState("Default Name Here");
  return(
    <WelcomeName
      name={name}
    />
  );
}

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

C Example