component

Define the components

Component names must start with a capital letter. React treats components that start with a lowercase letter as native DOM tags

Video Tutorial Address

  1. Function component

    export function Welcome() {
        return <h1>Hello</h1>
    }
    
    Copy the code
  2. The class components

    // File welcome.tsx
    import React, {Component} from "react";
    
    export default class Welcome extends Component<any.any> {
     render() {
            return (
                <h1>
                    Hello
                </h1>)}}Copy the code

Using the component

import React from 'react';
import {Welcome} from "./Welcome";

function App() {
    return (
        <>
            <Welcome/>
        </>

    );
}

export default App;

Copy the code