O'Reilly logo

React 16 Tooling by Adam Boduch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required