Skip to Content
React 16 Tooling
book

React 16 Tooling

by Adam Boduch, Christopher Pitt
April 2018
Intermediate to advanced content levelIntermediate to advanced
298 pages
6h 34m
English
Packt Publishing
Content preview from React 16 Tooling

Primitive property values

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro React 16

Pro React 16

Adam Freeman

Publisher Resources

ISBN: 9781788835015Supplemental Content