课程: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
JSX syntax
- [Presenter] So far we wrote a very simple React component, and configured the system to render it. Npm run dev server, and this is here, is the current state of the application. This syntax here, and also on line 10, right here, is called JSX. Let's talk about what else can we do with JSX. We can nest elements, just like HTML. Let me put, Hello React, in an <h1>. And in an <h2>, let's put another element. Save and this is fine. A component can return a tree of elements. You can also inject dynamic JavaScript in here, using the curly braces syntax {}. In here we can put any JavaScript call, and React will take the output of that call, and include it in the DOM. These expressions in curly braces, are very handy for two popular cases. When we need to conditionally render elements, and when we need to render elements, from a dynamic collection. Let's talk about both of these cases. First you need to understand, that…