Getting started with React

Just like Angular, React is component based. Angular is called a framework, whereas React is called a library. This means that Angular provides a lot of different functionalities and React provides one functionality, views. In the first two chapters, we used the HTTP service of Angular. React does not provide such a service, but you can use other libraries from npm instead.

Creating a component with JSX

A component is a class that has a render method. That method will render the view and is the replacement of the template in Angular. A simple component would look like the following:

export class Example extends React.Component<{}, {}> { render() { const name = "World"; return ( <div> Hello, { name }! <button onClick={() ...

Get TypeScript: Modern JavaScript Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.