2.
What is the output of the following React code?
import React from 'react';
function App() {
const name = "John";
return (
<div>
<h1>Hello, {name}!</h1>
</div>
);
}
export default App;
"Hello, John!"
"Hello, {name}!"
An error will occur
An empty page will be displayed
Correct: A
The code renders a single React component called App, which returns a JSX element containing a div element with an h1 element inside. The h1 element includes a dynamic value obtained from the name variable, resulting in the text "Hello, John!" being displayed on the page.