April 2018
Intermediate to advanced
298 pages
6h 34m
English
The most common types of values that are passed to components via props are primitive values—strings, numbers, and Booleans for example. Using Flow, you can declare your own type that says which primitive values are allowed for a given property.
Let's take a look at an example:
// @flow
import React from 'react';
type Props = {
name: string,
version: number
};
const Intro = ({ name, version }: Props) => (
<p className="App-intro">
<strong>{name}:</strong>{version}
</p>
);
export default Intro;
This component renders the name and version of some app. These values are passed in through property values. For this component, let's say that you only want string values for the name property and number values for the