React Holiday

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?