The Render Method -
The render () method is used to display the actual outputs HTML to the DOM.
The render () method is required and this method has to return something whether it is null.
Explore to Understand - React Lifecycle Components
When Render method is called?
When render method is called it returns a new virtual DOM structure of the component.
As an Example,
import React from 'react';
class Header extends React.Component {
constructor(props) {
super(props);
this.state = {msg: "welcome!"};
}
render() {
return (
<h2>{this.state.msg} you anil</h2>
);
}
}
As an another Example,
public class Header extends React.Component {
render() {
return (
<h2>This one is a Header component</h2>
);
}
}