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

Function property values

It's perfectly normal to pass functions from one component to another as a property. You can use Flow to ensure that not only are functions passed to the component, but also that the correction type of function is passed.

Let's examine this idea by looking at a common pattern in React applications. Let's say that you have the following Articles component that renders Article components:

// @flow import React, { Component } from 'react'; import Article from './Article'; type Props = {}; type State = { summary: string, selected: number | null, articles: Array<{ title: string, summary: string}> }; class Articles extends Component<Props, State> { state = { summary: '', selected: null, articles: [ { title: 'First Title', ...
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