Last active
November 27, 2017 04:29
-
-
Save rhiokim/b2321aff1c091254a95c0b347177b330 to your computer and use it in GitHub Desktop.
Flowtype fundamentals with React.js Raw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @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