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.

React is not defined: auto jsx runtime

See original GitHub issue

Hi, I depend on this package as a dependency of another npm package and I believe this issue: https://github.com/FezVrasta/react-resize-aware/issues/57 is seeing the same problem I see.

When I build with Vite with the auto jsx runtime available in React 17 I cannot use this package due to its microbundle distribution. and I get the error React is not defined.

I found that if I updated microbundle to latest and made an adjusted build for the jsx runtime, that I could use patch-package and still use this dependency.

The modified build command would be something like microbundle --name useResizeAware --jsx jsx --jsxImportSource react --globals react/jsx-runtime=jsx This was based on a suggestion here: https://github.com/developit/microbundle/issues/763#issuecomment-778848944

I was just wondering if you would consider releasing a package with support for the auto jsx runtime? At least for my situation turning off the auto JSX runtime is not an option I have right now. I would be happy to submit a PR with the build changes, but my only concern would be testing it for other environments.

Thanks! ✌🏻

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
timothyallancommented, Nov 21, 2022

@timothyallan whats the issue with just sticking with 3.1.1? If you look at the releases, there are no functional changes that you need.

Primarily because 3.1.2 is a bigger number than 3.1.1, therefore it must be better, and I want my package.json to have the biggest numbers in town for everything.

1reaction
johnnyomaircommented, Nov 17, 2022

PRs are more than welcome 🙏

I’m sorry, we decided to use ResizeObserver instead. 🙃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Importing react/jsx-runtime breaks dev builds #6215 - GitHub
Describe the bug When importing react/jsx-runtime, dev build breaks ... Uncaught ReferenceError: module is not defined at jsx-runtime.js:6.
Read more >
Uncaught ReferenceError: React is not defined - Stack Overflow
My index.js file looked like this when I was getting Uncaught ReferenceError: React is not defined . import {render} from 'react-dom'; ...
Read more >
Introducing the New JSX Transform – React Blog
Starting from Babel 8, "automatic" will be the default runtime for both plugins. For more information, check out the Babel documentation for @ ......
Read more >
babel/plugin-transform-react-jsx - Babel 中文文档
Automatic runtime is a feature added in v7.9.0 . With this runtime enabled, the functions that JSX compiles to will be imported automatically....
Read more >
JSX Pragma - Theme UI
React v17 introduced a new JSX transform, also called "automatic runtime" ... JSX to use the automatic runtime (globally, for your entire app),...
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