In the previous chapters, we used Angular and in this chapter we used React. Angular and React are both focused on components, but there are differences, for instance, between the templates in Angular and the views in React. In this section, you can read more about these differences.
Angular uses a template for the view of a component. Such a template is a string that is parsed at runtime. TypeScript cannot check these templates. If you misspell a property name, you will not get a compile error.
React uses JSX, which is syntactic sugar around function calls. A JSX element is transformed, by the compiler, into a call to React.createElement
. The first argument is the name of the element or the element class, the second argument contains the props, and the other arguments are the children of the component. The following example demonstrates the transform:
<div></div>; React.createElement("div", null); <div prop="a"...