coding180 icon

What is the purpose of render() in React?

Home > Interviews > Javascript

robort - 2022-10-05 06:30:00

Every React component must have a render()function . The render function is used to return the HTML to be displayed in the component. If multiple HTML elements need to be rendered, they need to be grouped together in a single enclosing tag (parent tag), eg <div>, <form>, , <group>etc. This function returns the same result every time it is called.

Example: If you need to display the title, you can do it as follows:

import React from 'react'  

class App extends React.Component {  
   render (){  
      return (  
         <h1>Hello World</h1>  
export default App



  • Each render()function contains a return statement.
  • returnA statement can only have one parent HTML tag.


Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel