It seems there is a problem when the img rendering
An object inserted into the src attribute.
React version: 16.14.0
Link to code example: https://github.com/hosseinmd/test-new-jsx
img src is an object
Expected to insert url of image to src
@gaearon Please test it I couldn't solve the problem.
@hosseinmd you cannot use require try to do it this way
import logo from './logo192.png
it works so i don't think it's an issue just a matter of syntax
@hosseinmd you cannot use require try to do it this way
import logo from './logo192.png
it works so i don't think it's an issue just a matter of syntax
Yes, import is working, but the question is:
Why I cannot use require?
This is about the next version of react-scripts.
This is about the next version of react-scripts.
This issue should be filed against facebook/create-react-app. This repository is for issues caused by react
and friends (e.g react-dom
).
I tested the newly released v4 still has this issue.
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
For some reason in CRA v4 require
returns an ES module, I do not know if this is done intentionally, or it is just a bug, but the only workaround for now is:
const logo = require('./logo192.png').default;
CRA still has this bug. This is an emergency issue.
I am not sure it's a bug, again, it's unclear whether this was done intentionally or not, but the fact, it's happening because of an upgrade of file-loader
from v4 to v6. Since version 5.0.0 file-loader
has a breaking change, esModule
option is enabled by default, that's why require
now returns an ES module, instead of a string.
@gaearon I don't know if this was explained elsewhere, but it needs to be clarified whether this is a bug or a feature.
Is there a fork or PR available to configure this to use the old behavior?
Got the same issue. Requiring produces [Object Module] in the browser.
Most helpful comment
I am not sure it's a bug, again, it's unclear whether this was done intentionally or not, but the fact, it's happening because of an upgrade of
file-loader
from v4 to v6. Since version 5.0.0file-loader
has a breaking change,esModule
option is enabled by default, that's whyrequire
now returns an ES module, instead of a string.@gaearon I don't know if this was explained elsewhere, but it needs to be clarified whether this is a bug or a feature.