react js class compenent constructor code example
Example 1: react native class component constructor
import React from 'react';
import { View, TextInput } from "react-native";
class App extends React.Component {
constructor(props){
super(props);
this.state = {
name: ""
}
this.handleChange = this.handleChange.bind(this);
}
handleChange(text){
this.setState({ name: text })
console.log(this.props);
}
render() {
return (
this.handleChange(text)}
/>
}
}
export default App;
Example 2: react.component
class Welcome extends React.Component {
render() {
return Hello, {this.props.name}
;
}
}