react-koa2-ssr icon indicating copy to clipboard operation
react-koa2-ssr copied to clipboard

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

Open nickzym opened this issue 6 years ago • 3 comments

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')} />

nickzym avatar Mar 29 '18 16:03 nickzym

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

yangfan0095 avatar Mar 30 '18 15:03 yangfan0095

@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 avatar Mar 31 '18 04:03 yangfan0095