react-resize-aware
react-resize-aware copied to clipboard
React is not defined: auto jsx runtime
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! ✌🏻
Thanks, could you please test it with [email protected]
?
I will thanks!
@FezVrasta That doesn't work for me, I get jsx
is undefined. But you're still using a very old version of microbundle, maybe thats the issue? In my version I updated microbundle to latest.
Could you please try 3.1.1-issue-58.1
?
@samueljseay ?
@samueljseay may you please provide some feedback?
@FezVrasta it seems that v3.1.2 breaks applications using the old JSX transform. I'm getting the error ReferenceError: jsx is not defined
PRs are more than welcome 🙏
I believe it has something to do with setting --globals react/jsx-runtime=jsx
.
3.1.2 borked our entire app with ReferenceError: jsx is not defined
as well. Are there any workarounds other than downgrading to 3.1.1 again?
We also got the ReferenceError: jsx is not defined
when using 3.1.2 😢
@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.
@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.
whats the issue with just sticking with 3.1.1?
3.1.1 does not support React 18 (see https://github.com/FezVrasta/react-resize-aware/issues/59)
Still getting this as of feb 2022
This seems to be an issue still. 3.1.1 resolves this, but this is coming up deep in a dependency tree from some other packages we're using, and 3.1.2 is being installed by default, which makes it fail. I've manually installed 3.1.1 to override the one from the package we're using. I lost sooooo many hours trying to diagnose what was happening here.
Hi, Do we have any solution to the issue "Uncaught ReferenceError: jsx is not defined". With NPM downgraded version is not available as well
You can install the previous version that's compatible with the old jsx system.
For those using jest and running into the JSX undefined issue, you can try simply mocking the hook:
jest.mock('react-resize-aware', () =>
jest.fn().mockReturnValue([null, { width: 0 }])
);
Seems like v3.1.3 was released on npm yesterday, despite nothing here on GitHub. Has anyone given it a try to see if it solves this issue?
https://www.npmjs.com/package/react-resize-aware/v/3.1.3
I haven't changed that in the last release. But I plan to work on it tomorrow.
4.0.0 should address this problem