server rendering and images #75
Comments
Doesn't it work that way? reactLogo = require('../images/react-logo.png');
export default class Header extends React.Component {
render() {
return (
<div>
<img src={reactLogo} height="60" />
<header> |
Well I guess I use it the wrong way. Rendering is made by an express server side instance which render a react component and enhances an html template. This html template links a bundle.js packed by webpack, in this bundle image src is fine because generated by webpack process. But on server side src is missing. |
Test is made this way if (process.env.BROWSER) {
reactLogo = require('./images/react-logo.png');
// css require then, but are fine as React do not care about it.
} but for express server I do not figure out how to match rendering image in component |
Thanks for adding an example, I was not bundling my server side with webpack which caused problem. It looks solve on my side too. What a crazy solution then webpack. Very impressive |
You need to apply your webpack to both client and server code files at the same time. It will use same hashes, otherwise will be different and react won't be happy |
Hi,
First just insane job you have done, bravo !
Could you give some explanations when using jsx rendering on server side with images and the following known message. I know the purpose of it but can not find any solutions to fix it:
This question might be out of react-starter context but how to deal with it when rendering is made on server side with component containing a reference to image not in css but with img html tag ?
My component code is something like:
Webpack bundle contains image hashed name but when rendered on server side with expressjs in my case I do not see how to handle this case.
Thx,
Julien
The text was updated successfully, but these errors were encountered: