create a react component code example
Example 1: how to create component in reactjs
class Car extends React.Component {
render() {
return <h2>Hi, I am a Car!</h2>;
}
}
Example 2: functional component react
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
function App() {
return (
<div>
<Welcome name="Sara" /> <Welcome name="Cahal" /> <Welcome name="Edite" /> </div>
);
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
Example 3: react component example
const element = <div />;