How to learn react logo

These tutorials will give you a deeper understanding of React.js. Learn with examples from the Javascript UI library, covering the basics and the advanced.

Browse by tag:

Using JSX to mount a DOM element and display it in a web browser

DOM

In theory, we could actually build out an entire application using the createElement method. But eventually, as our application scales, itโ€™ll get really complex and hard to reason. This is why React gave us an abstraction on top of this method, called JSX.

React takes your JSX and boils it down through React.createElement() calls that is why itโ€™s important to understand a little bit about this particular method.

  1. Use something like Babel transpile your JSX into a regular version of JavaScript so that Chrome can read it. To get babel-standalone included into our html file for now, we can simply use the UNPKG cdn to retrieve it.
<script crossorigin src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script>
  1. Refactor our myElement variable to use JSX instead of React.createElement()
const myElement = React.createElement('h1', {className:'heading'}, 'Hello World');

// becomes

const myElement = <h1 className="heading" >Hello World</h1>;

Challenge

From scratch, build out a React application within an HTML file that will mount an header with your name, age and location. Use a <style> tag to add some CSS and make your profile you just built look nice and pretty.

How To Learn React is designed and developed by me, Blake Fletcher. It is a project intended to share the things I learn while working with the UI library. As I build things, complete tutorials, read blog posts, and watch videos, I'll add to the site. I hope to eventually bring on other contributors. If interested, send me an email at blkfltchr@gmail.com.