React elements are the smallest building blocks of a React application. They are different from DOM elements and they represent a description of what you want to see on the screen. For example, a DOM node like a To render a React element to the browser’s DOM, you need a container or root DOM element, typically a To render a simple React element using a functional component, add the following code to the App.js file. To mount this component into the root element: Output: React elements are designed to be immutable building blocks of the UI. Below is an example of a functional component that updates the current time every second using the useEffect and useState hooks for dynamic rendering. Write the following code in App.js file of your project directory. Output: The time updates every second, while the heading remains static. React’s efficiency comes from its Virtual DOM and diffing algorithm, which minimize actual DOM updates. The rendering process involves: These best practices help improve performance and ensure smoother and more efficient rendering in React applications.Rendering an Element in React
// App.js
import React from 'react';
function App() {
return (
<div>
<h1>Welcome to GeeksforGeeks!</h1>
</div>
);
}
export default App;
// index.js
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);

Updating an Element in React
Example: Updating Time with Functional Component
import React, { useEffect, useState } from 'react';
import ReactDOM from 'react-dom/client';
function App() {
const [currentTime, setCurrentTime] = useState(new Date().toLocaleTimeString());
useEffect(() => {
const interval = setInterval(() => {
setCurrentTime(new Date().toLocaleTimeString());
}, 1000);
return () => clearInterval(interval); // Cleanup on unmount
}, []);
return (
<div>
<h1>Welcome to GeeksforGeeks!</h1>
<h2>{currentTime}</h2>
</div>
);
}
// Render the component
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
export default App;

How It Works?
element is re-rendered, leaving the static
unchanged.
React Render Efficiency
Best Practices for Efficient Rendering
or a user-defined component.
with an id like root or app. For example, your index.html file might include:
javascript
JavaScript
javascript