Error: React is not defined
See original GitHub issueDo you want to request a feature or report a bug?
bug
What is the current behavior?
Using react-toastify with @vitejs/plugin-react v2.0.0
and vite v3.0.0
throws
ReferenceError: React is not defined
only in Production.
After getting the error, I enabled sourcemap and found the error in react-toastify
esm build.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:
Use @vitejs/plugin-react v2.0.0
and vite v3.0.0
and use toast.error('message')
and you’ll get the error
What is the expected behavior? It shouldn’t throw. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? It works in both react 17 and 18 when using vite v2 but it’s throwing in vite 3 as vite 3 uses esm.
I’m not sure if it’s a vitejs plugin but or react-toastify. Lmk should I create the issue in vitejs plugin instead.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:17 (9 by maintainers)
Top GitHub Comments
@imranbarbhuiya pushed v9.0.7
Awesome I’ll publish a new version tomorrow then