Content deleted Content added
Reverted good faith edits by Atishe C (talk): Unsourced |
m →Basic usage: Spelling (ref. <https://en.wikipedia.org/wiki/%22Hello,_World!%22_program>). |
||
Line 31:
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 our Greeter component inside the [[Document Object Model|DOM]] element with id <code>myReactApp</code>.
When displayed in a web browser the result will be
<syntaxhighlight lang="html">
<div id="myReactApp">
<h1>Hello, World!</h1>
</div>
</syntaxhighlight>
|