// @flow import React from 'react'; import type {Node} from 'react'; class MyComponent extends React.Component<{children: Node, ...}, void> { render(): Node { // OK: Can pass a node down like so. return {this.props.children}; } } class MyComponentOptional extends React.Component<{children?: Node, ...}, void> {} ; // Error: `children` is required. ; // Error: `children` is required. ; // OK: `children` may be a string. {}; // Error: `children` is required. ; // OK: `children` is optional. ; // OK: `children` is optional. ; // OK: `children` may be a string. {}; // OK: `children` is optional. // OK: The `ReactNode` allows any children. {} {undefined} {null} {true} {false} {0} {42} {'hello world'} foobar {[undefined, null, true, false, 0, 42, 'hello world', 'foobar', ]} ; // Error: Arbitrary objects are not allowed as children with `ReactNode`. {{a: 1, b: 2, c: 3}} ;