Flow: New JSX transform not working with Flow

Created on 26 Oct 2020  路  4Comments  路  Source: facebook/flow

Flow version: 0.136.0

Expected behavior

I should be allowed to use JSX without importing React, as described by the React blog post:
https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#flow

Actual behavior

Cannot resolve name `React`. [cannot-resolve-name]

  • Link to Try-Flow or Github repo:

https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAeAJgSwG5jAB8QA

bug needs triage

All 4 comments

I was informed on Discord that there's an option to enable to make Flow understand the new JSX transform.

[options]
react.runtime=automatic

I can't find it documented anywhere in the docs though.

It's documented: https://flow.org/en/docs/config/options/#toc-react-runtime-automatic-classic

But it doesn't seem to work with focus-check.

Deleting babel from the Package.json
"babel": { "presets": [ "react-app" ] }

and creating a new babel.config.json file in the root directory of the project with the following code in it worked for me:

{ "presets": [ ["@babel/preset-react", { "runtime": "automatic" }] ] }

Why do we need to set it to automatic? The docs say:

The default value is automatic.

Was this page helpful?
0 / 5 - 0 ratings