Skip to content

Commit a08a579

Browse files
authored
Added example
1 parent 3aa50af commit a08a579

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

4.html

+11
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ <h1>JSX</h1>
6060
<section style="text-align: left;">
6161
<h2>Example</h2>
6262
<pre><code class="hljs">
63+
import * as React from "react";
64+
import { render } from "react-dom"
65+
6366
class ShoppingList extends React.Component {
6467
render() {
6568
return (
@@ -74,6 +77,14 @@ <h1>Shopping List for {this.props.name}</h1>
7477
);
7578
}
7679
}
80+
81+
let baseDiv = document.querySelector("#root");
82+
83+
// Note the this.props.name. We can pass that prop during construction as below:
84+
// Props in react are just attributes on their
85+
86+
// Below is the render function from react-dom. It injects a react component into a component in the regular dom.
87+
render(<ShoppingList name="Whatever" />, baseDiv)
7788
</code></pre>
7889
</section>
7990
</div>

0 commit comments

Comments
 (0)