react native class component code example
Example 1: react native class component
class Cat extends Component {
render() {
return Hello, I am your cat!;
}
}
Example 2: class in react
class App extends Component {
constructor() {
super()
this.state = {
name: "Sally",
age: 13
}
}
render() {
return (
{this.state.name}
{this.state.age} years old
)
}
}
Example 3: create react component class
class MyComponent extends React.Component{
constructor(props){
super(props);
};
render(){
return(
My First React Component!
);
}
};
Example 4: class app extends component syntax
class Welcome extends React.Component {
render() {
return Hello, {this.props.name}
;
}
}
Example 5: how to create component in reactjs
class Car extends React.Component {
render() {
return Hi, I am a Car!
;
}
}
Example 6: functional components react
function Comment(props) {
return (
{props.author.name}
{props.text}
{formatDate(props.date)}
);
}