Skip to content

Instantly share code, notes, and snippets.

@rhiokim
Last active November 27, 2017 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhiokim/b2321aff1c091254a95c0b347177b330 to your computer and use it in GitHub Desktop.
Save rhiokim/b2321aff1c091254a95c0b347177b330 to your computer and use it in GitHub Desktop.
Flowtype fundamentals with React.js Raw
// @flow
import React from 'react'
type PropsA = {
children?: React.Node
}
const A = (props: PropsA) => (
<div>
{props.children}
</div>
)
const ComponentA = () => <A>Test</A>
type PropsB = {
children: React.Element<any>
}
const B = (props: PropsB) => (
<div>
{props.children}
</div>
)
const ComponentB1 = () => <B/> // error
const ComponentB2 = () => <B>text</B> // error
const ComponentB3 = () => <B><span>text</span></B> // works!
const ComponentB4 = () => <B><span>foo</span><span>bar</span></B> // error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment