Properties and state

As we can see in the preceding code snippet, the Component class is a generic class with two optional generic types: Component<TProps, TState>. These two generic types allow us to specify the type of the properties and state used in a React component.

As you can see, the Container and the Row components don't have any properties or state. However, the Column component defines the type of its properties because we need some additional data to be provided by its consumers. For example, when we declare the Column component, we don't know if the consumers will set its size to 1 or 12.

Properties are passed to a component via its constructor by the consumers of the component. For example, the following code snippet demonstrates ...

Get Learning TypeScript 2.x - Second Edition 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.