New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React children accepts function when explicitly typed #6889

Open
arahansen opened this Issue Sep 13, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@arahansen

arahansen commented Sep 13, 2018

this flow.org/try example demonstrates the same input to react children being treated differently by flow.

My understanding is that for built in html elements, children should be React.Node. However, React.Nodes should not be functions. The first example shows this behavior. However, if the function is explicitly typed, flow will not error on the react element.

Code:

import * as React from 'react'

const func = () => 'lol'

// fails
const comp = <div>{func}</div>
      
const otherFunc: () => string = () => 'hey now'

// no failure
const otherComp = <div>{otherFunc}</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment