Skip to content

Commit

Permalink
React.createElement syntax (#9459)
Browse files Browse the repository at this point in the history
* React.createElement syntax

Added React.createElement syntax.
I think this is required for this tutorial.

* Reword
  • Loading branch information
Radi123 authored and gaearon committed Apr 26, 2017
1 parent d6cc1d1 commit 9824d52
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/tutorial/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ The `render` method returns a *description* of what you want to render, and then

```javascript
return React.createElement('div', {className: 'shopping-list'},
React.createElement('h1', ...),
React.createElement('ul', ...)
React.createElement('h1', /* ... h1 children ... */),
React.createElement('ul', /* ... ul children ... */)
);
```

If you're curious, `createElement()` is described in more detail in the [API reference](/react/docs/react-api.html#createelement), but we won't be using it directly in this tutorial. Instead, we will keep using JSX.

You can put any JavaScript expression within braces inside JSX. Each React element is a real JavaScript object that you can store in a variable or pass around your program.

The `ShoppingList` component only renders built-in DOM components, but you can compose custom React components just as easily, by writing `<ShoppingList />`. Each component is encapsulated so it can operate independently, which allows you to build complex UIs out of simple components.
Expand Down

0 comments on commit 9824d52

Please sign in to comment.