JSX

Creating elements with this syntax can be quite cumbersome, especially once you get to the point where you’re nesting elements. Most rect apps use a Javascript syntax extension called JSX. It looks a lot like HTML, but do not be confused, it is not HTML. Lets redefine our “What” with JSX. We’ll do an opening tag like we would with any HTML element, and in here type “Hello, React!”. You don’t need to add any additional strings or anything. Very simple. Now this syntax and this are identical. They are doing exactly the same thing, but this allows us to have a nicer authoring experience. One that feels a little bit more familiar if we’ve had years of writing HTML. It’s also a little bit more terse. React comes with a few “gotchas”, and these become a little bit worse when you’re working with JSX. For example, you might be used to saying class=”header”. In React that becomes the property name className. This is the same for event handlers. Say instead of having an onclick that is all lower case and looks like this, your onClick is going to be camel cased. This is the react version of that same thing. This applies for all of the events. Now, apart from being useful and a little bit weird, this is the syntax that I see in all of the react application I have ever seen or built. So like it or not, it’s just something that you get used to.

Play video: JSX
  1. Course overview
  2. Project setup
  3. ReactDOM.render and React.createElement
  4. 👉JSX
  5. Functional components
  6. Props
  7. Class Components
  8. onClick and other events
  9. Component initial state
  10. setState - object form
  11. setState - functional form
  12. Conditional rendering in JSX
  13. essential react 13
  14. Fetching pokeapi data
  15. componentDidMount
  16. setState and fetch
  17. Lists with Array.map()
  18. componentWillReceiveProps
  19. Component props
  20. Render props
  21. Separation of Concerns with components
  22. Higher-order components
  23. defaultProps
  24. Render prop actions
  25. Course summary