Skip to content
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

Warning: Prop src did not match. Server: "[object Object]" Client: "/image/EH_jxxr.png" #4

Open
nickzym opened this issue Mar 29, 2018 · 3 comments

Comments

@nickzym
Copy link

nickzym commented Mar 29, 2018

When the site load in react(webpack-dev-server) the images load fine, but when run in koa sever, it gives me a warning like above. what can do?, I hope your's help, thanks.

I use a react component like <Image src={require('./image/iphone.jpg')} />

@yangfan0095
Copy link
Owner

@nickzym got it , I will deal this problem as soon as possible 🙂

@yangfan0095
Copy link
Owner

@nickzym hey thank you put this issues so much 👍👍 , now this problem has been solved .

the problem caused because when server side resolve React Component , it cannot load sources like assets file , so we solve it by add a hook to import asset files during runtime .

the key code as follow :

+require('asset-require-hook')({
+    extensions: ['jpg', 'png', 'gif','webp'],
+    limit: 10000,
+    name:'static/media/[name].[ext]'
+});

the code had been committed on master , and you can git pull it .😉

@yangfan0095
Copy link
Owner

and the url for https://www.npmjs.com/package/asset-require-hook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants