question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Needs documentation for how to use new JSX transform

See original GitHub issue

Summary

React says that Gatsby 2.24.+ supports the new JSX transform (and there’s a merged PR here claiming it is supported) so we don’t need to import * as React from 'react' anymore for React 17. So I started a new Gatsby project (2.26.x). It installed React 16.x, which doesn’t support the new transform. I updated react and react-dom to 17.0.1 and removed the import * as React from 'react' line from src/pages/index.js and now I get a bunch of

101:5   error  'React' must be in scope when using JSX react/react-in-jsx-scope

for that file.

Motivation

It should be documented because React and Gatsby both claim to support this for React 17, but there do not seem to be instructions for how to make this work.

Steps to resolve this issue

Hell if I know. I’ve been trying to get this to work for a couple days now. Once it’s working, I’m going to try to get it working with TypeScript, which I also failed to get working the past day.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
Austarascommented, Dec 17, 2021

@kylegoetz Thanks for opening the issue. We’re working on supporting the new jsx transforms. Currently they are not supported unless you create a custom babelrc and mimic what babel-preset-gatsby does.

@wardpeet any progress or roadmap yet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing the New JSX Transform – React Blog
When you use JSX, the compiler transforms it into React function calls that the browser can understand. The old JSX transform turned JSX...
Read more >
How to Use New JSX Transform IN REACT - Aspire Blogs
New JSX Transform in React blog presents what and why new JSX Transform use, JSX advantages, disadvantages and JSX hook examples.
Read more >
How to enable new JSX transform in React?
Yes! You'll no longer need to import React to each. and. every. component. you write. Instead, it will be imported automatically!
Read more >
React 17: New JSX Transform - In Plain English
A guide to integrating the new JSX transform. ... JSX transform is needed so your source code can be converted into code the...
Read more >
babel/plugin-transform-react-jsx
If you do not want (or cannot use) auto importing, you can use the classic runtime, which is the default behavior for v7...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found