Flow: Error when using React.createElement directly

Created on 19 Aug 2017  路  4Comments  路  Source: facebook/flow

I'm not a big fan of JSX and prefer to use React.createElement directly.

The Babel REPL link from the "Hello World" page from React docs shows <h1>Hello, world!</h1> transpiling to

React.createElement(
  'h1',
  null,
  'Hello, world!'
)

If I try this in Try Flow with 0.53.1, I get the following errors:

2: React.createElement('h1', null, 'Hello, world!')
                             ^ React key. Property not found in possibly null value
2: React.createElement('h1', null, 'Hello, world!')
                             ^ null
2: React.createElement('h1', null, 'Hello, world!')
                             ^ React ref. Property not found in possibly null value
2: React.createElement('h1', null, 'Hello, world!')
                             ^ null

However, React.createElement('h1', {}, 'Hello, world!') works fine.

Is this a bug in Flow or expected behavior?

bug react

Most helpful comment

@asolove it got closed by https://github.com/facebook/flow/commit/30f8e7b1c548702587d8e9c7972a7194a0cd0fca, which has "fixes #4658 in the title".

That said, it's still an issue in 0.54.0

All 4 comments

It looks like this is still an issue in 0.54.0:
https://flow.org/try/#0PTAEAEDMBsHsHcBQiCWBbADrATgF1AFSgCGAzqAEoCmxAxvpNrGqAETY32sDcyuAnhiqgAYrFgAFJhnIBeUAG8APogCQtABYpoAEw4A7AFyhSubCn0BzREoC+yWrH2nR449Tq4AdAGVcxXCpoKlJSEQBXfXoUJ2JoAGFmLH0qfVwAHjFJaVIAPlB5DByC3LV0nRQAN1yi2BkvTW09VPTgCuqHJxcAIWJsd05vPwCgkLDI6NiEpKdUjIVbfPkACgBKErKs3IAjPtatzud8XoAvAc9ff0Dg0Iio3Bj9OMTMWbT0haXQNY3VD3oGhwRgBRYJoObLLIAGlA+nC0GgMIA5LsTkjVkA

Looks like this was closed incorrectly. (Edit: previous explanation here was wrong) (/cc @calebmer)

@asolove it got closed by https://github.com/facebook/flow/commit/30f8e7b1c548702587d8e9c7972a7194a0cd0fca, which has "fixes #4658 in the title".

That said, it's still an issue in 0.54.0

The fix didn't make the cut for 0.54; it will come out with 0.55.0. Feel free to reopen if the issue persists after that.

Was this page helpful?
0 / 5 - 0 ratings