From 290f6d6b47c774c7b4252db4641a0b9b92418118 Mon Sep 17 00:00:00 2001 From: RSG Date: Wed, 26 Apr 2017 16:25:40 +0300 Subject: [PATCH] React.createElement syntax (#9459) * React.createElement syntax Added React.createElement syntax. I think this is required for this tutorial. * Reword --- tutorial/tutorial.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tutorial/tutorial.md b/tutorial/tutorial.md index 7feca45b..76b33065 100644 --- a/tutorial/tutorial.md +++ b/tutorial/tutorial.md @@ -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 ``. Each component is encapsulated so it can operate independently, which allows you to build complex UIs out of simple components.