react-koa2-ssr
react-koa2-ssr copied to clipboard
Warning: Prop `src` did not match. Server: "[object Object]" Client: "/image/EH_jxxr.png"
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 got it , I will deal this problem as soon as possible 🙂
@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 .😉
and the url for https://www.npmjs.com/package/asset-require-hook