Day 1: Hello ๐
In C
, programs have a main()
function.
Itโs where programs starts.
React apps are similar; on the web they start with ReactDOM.render()
.
ReactDOM.render(someReactComponent, someDOMNode);
WTF is ReactDOM?
React is used all overโweb, mobile, desktop, VR, appliances. Lots of places.
Instead of stuffing all those smarts into one enormous library, each platform has a partner library.
On the web, thatโs ReactDOM
.
We use React
to create components and ReactDOM
to render them into the DOM.
ReactDOM.render(
React.createElement("h1", {}, "Hello ๐"),
document.getElementById("root")
);
Tinker with it
Use the window below and play around with render()
.
- Comment out the import statements. What errors do you get?
- Change the component type to something other than
h1
. - Put some values in the empty object (second argument). What happens? What errors do you get?