Js.React.Functional and class style

Both are equivalent

const FunctionalGreeting = (props) => {
    return <div>Hello world from function, {props.name} </div>
}

class ClassGreeting extends React.Component {
    render() {
        return <div>Hello world from class {this.props.name}</div>
    }
}

export const PleaseRender = () => {
    return (
        <div>
            <FunctionalGreeting name="Stanley" />
            <br />
            <ClassGreeting name="Stanley" />
        </div>

    );
}

This entry was posted in Без рубрики. Bookmark the permalink.