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.

Error: React is not defined

See original GitHub issue

Do 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. image

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:closed
  • Created a year ago
  • Reactions:2
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
fkhadracommented, Jul 19, 2022

@imranbarbhuiya pushed v9.0.7

2reactions
fkhadracommented, Jul 18, 2022

Awesome I’ll publish a new version tomorrow then

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: React is not defined - Stack Overflow
Possible reasons are 1. you didn't load React.JS into your page, 2. you loaded it ...
Read more >
Getting "Uncaught ReferenceError: react is not defined".
Hi Louie Ambriz, It's hard to tell without seeing your code but it sounds like React is not being loaded into your project....
Read more >
[v4]ReferenceError: React is not defined · Issue #9882 - GitHub
I have submitted PR #9885 to fix this. This is because the jsx-runtime configuration gets removed webpack config during the ejection process ......
Read more >
Uncaught ReferenceError: React is not defined
my code works fine with production cdn, when i change it to development version it gives this error. Why does the production version...
Read more >
React is not defined after migrating to React 17 - Meteor forums
Hello, I migrated to React v17. I know that now it is not necessary to import React from 'react'; so I deleted it...
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