React JSX
Translation results:
React uses JSX instead of regular JavaScript.
JSX is a JavaScript syntax extension that looks a lot like XML.
React JSXsyntax
We don't necessarily need to use JSX, but it has the following advantages:
JSX executes faster because it is optimized after being compiled into JavaScript code.
It is type-safe and errors can be found during the compilation process.
Writing templates using JSX is simpler and faster.
React JSXexample
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>php.cn React 实例</title> <script src="https://cdn.bootcss.com/react/15.4.2/react.min.js"></script> <script src="https://cdn.bootcss.com/react/15.4.2/react-dom.min.js"></script> <script src="https://cdn.bootcss.com/babel-standalone/6.22.1/babel.min.js"></script> </head> <body> <div id="example"></div> <script type="text/babel"> ReactDOM.render( <div> <h1>php中文网</h1> <h2>欢迎学习 React</h2> <p data-myattribute = "somevalue">这是一个很不错的 JavaScript 库!</p> </div> , document.getElementById('example') ); </script> </body> </html>
Run instance »
Click the "Run instance" button to view the online instance
Popular Recommendations
- How React JSX Gets Transformed Into JavaScript Behind the Scenes
- Dynamic Manipulation of Children in React JSX with React.cloneElement and React.Children.map
- JSX (JavaScript XML)
- React native tab view error :A props object containing a \"key\" prop is being spread into JSX
- Dynamic Layouts with Vue jsx: A Guide to Flexible and Maintainable UIs
- React Basics