React (software): Difference between revisions

Content deleted Content added
m redirect bypass from Meta, Inc. to Meta Platforms using popups
Testing your functionality
Tags: Reverted possible vandalism Visual edit
Line 27:
The following is a rudimentary example of React usage in HTML with [[React (JavaScript library)#JSX|JSX]] and JavaScript.
<syntaxhighlight lang="html" line="1">
hello G
<div id="myReactApp"></div>
 
<script type="text/babel">
function Greeter(props) {
return <h1>{props.greeting}</h1>;
}
let App = <Greeter greeting="Hello, World!" />;
ReactDOM.render(App, document.getElementById('myReactApp'));
</script>
</syntaxhighlight>
The <code>Greeter</code> function is a React component that accepts a property <code>greeting</code>. The variable <code>App</code> is an instance of the <code>Greeter</code> component where the <code>greeting</code> property is set to <code>'Hello, World!'</code>. The <code>ReactDOM.render</code> method then renders the Greeter component inside the [[Document Object Model|DOM]] element with id <code>myReactApp</code>.