react extend react.component code example
Example 1: react extend react.component
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}
Example 2: diagram how props are passed in react
import React, { Component } from 'react'; class App extends Component { render() { const greeting = 'Welcome to React'; return ( <div> <Greeting greeting={greeting} /> </div> ); }} class Greeting extends Component { render() { return <h1>{this.props.greeting}</h1>; }} export default App;