Browse Source

Add "Why JSX" (#424)

* Add "Why JSX"

* Update introducing-jsx.md
main
Dan Abramov 7 years ago
committed by GitHub
parent
commit
a3e8023829
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      content/docs/introducing-jsx.md

10
content/docs/introducing-jsx.md

@ -18,6 +18,16 @@ It is called JSX, and it is a syntax extension to JavaScript. We recommend using
JSX produces React "elements". We will explore rendering them to the DOM in the [next section](/docs/rendering-elements.html). Below, you can find the basics of JSX necessary to get you started.
### Why JSX?
React embraces the fact that rendering logic is inherently coupled with other UI logic: how events are handled, how the state changes over time, and how the data is prepared for display.
Instead of artificially separating *technologies* by putting markup and logic in separate files, React [separates *concerns*](https://en.wikipedia.org/wiki/Separation_of_concerns) with loosely coupled units called "components" that contain both. We will come back to components in a [further section](/docs/components-and-props.html), but if you're not yet comfortable putting markup in JS, [this talk](https://www.youtube.com/watch?v=x7cQ3mrcKaY) might convince you otherwise.
React [doesn't require](/docs/react-without-jsx.html) using JSX, but most people find it helpful as a visual aid when working with UI inside the JavaScript code. It also allows React to show more useful error and warning messages.
With that out of the way, let's get started!
### Embedding Expressions in JSX
You can embed any [JavaScript expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) in JSX by wrapping it in curly braces.

Loading…
Cancel
Save