In React, you can render HTML using JSX syntax. JSX allows you to write HTML-like code within your JavaScript code. Here’s an example:
import React from 'react';
function MyComponent() {
return (
<div>
<h1>Hello, world!</h1>
<p>This is a paragraph.</p>
<a href="https://example.com">Visit Example.com</a>
</div>
);
}
export default MyComponent;
In this example, the MyComponent
function returns JSX code that represents an HTML structure. You can include HTML elements such as div
, h1
, p
, and a
, and specify their attributes using standard HTML syntax.