-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Bug: Cannot use require() to display image on my machine. #10088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
So far no problems seen after running it both on sandbox and locally. But I do have a similar encounter in another project that also uses That project was using React Scripts 3.4.3 and React 16.13.1. The bug was observed after I updated them to 4.0.0 and 17.0.1 respectively. But I'm not sure if it was really caused by the version update. |
Yes. Adding |
Experiencing this as well. Only after react 17. |
this issue is still there and it is annoying. Just did npx create-react-app and tested image with require it loads |
Same issue for me, latest CRA with React |
Duplicate #9992 |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Describe the bug
Cannot use
require()
to display image on my machine. During preparation of this bug report I've created the same base code in Codesandbox and it works there.Did you try recovering your dependencies?
Which terms did you search for in User Guide?
require
Environment
Environment Info:
Steps to reproduce
npx create-react-app
.<img src={require("path/to/image/image.png")} />
in App.js render return.Expected behavior
Should display icon two times. Once using import variable, once using required. Works like that on Codesandbox website. Refer to demo below.
Actual behavior
This is how it looks while I'm running minimal example locally in project created with
npx create-react-app .
Reproducible demo
https://codesandbox.io/s/react-require-bug-1gh2i?file=/src/App.js:67-292
The text was updated successfully, but these errors were encountered: