Here's an example of a simple React component that displays a greeting message:

import React from 'react';

class Greeting extends React.Component {
  render() {
    return (
      <div>
        <h1>Hello, ' + this.props.name + '!</h1>
        <p>Welcome to my website.</p>
      </div>
    );
  }
}

export default Greeting;

In this component, we define a 'Greeting' class that extends the 'React.Component' class. The 'render()' method returns a JSX element that displays a greeting message, using the 'name' prop passed to the component. We export the 'Greeting' component as the default export, so that it can be imported and used in other parts of our application.

React JS Example: Simple Greeting Component

原文地址: https://www.cveoy.top/t/topic/oHcq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录