Git Product home page Git Product logo

Comments (6)

gregberge avatar gregberge commented on August 10, 2024

I don't understand the link between loadable-components and your screenshot, can you please give more context?

from loadable-components.

fadiquader avatar fadiquader commented on August 10, 2024

suppose you have project with cra, and you import image like the following

// App component 
import logo from './logo.svg';
....
<img src={logo} alt="logo" />

I think the problem with url loader, when component is rendering in server side, it doesn't resolve the path, and return empty object.
src="[object Object]"

from loadable-components.

gregberge avatar gregberge commented on August 10, 2024

Yeah probably, this is not relative to loadable-components. Your problem is a current server-side rendering issue. You are trying to use a Webpack loader server-side.

from loadable-components.

xFloooo avatar xFloooo commented on August 10, 2024

@neoziro
I have a similar problem, the server and the client generate different paths to the picture.

in component file

import gift from "../../icons/[email protected]";
...
render(){
    ...
    return <img alt={"gift"} className={classes.image} src={gift} />
}

After starting the application, I get Warning: Prop src did not match. Server: "/dist/node/application/icons/[email protected]" Client: "/dist/web/application/icons/[email protected]"

webpack.config - taken from your example for SSR with the addition url-loader

            {
                test: /\.(pdf|png|jpg|ttf|eot|svg|woff|woff2)(\?[a-z0-9#=&.]+)?$/,
                use: [
                    {
                        loader: "url-loader",
                        options: {
                            limit: 8192,
                            name: "[path][name].[ext]"
                        }
                    }
                ]
            }

could you help me with this?

from loadable-components.

xFloooo avatar xFloooo commented on August 10, 2024

solved a problem in webpack.config change publicPath

//publicPath: `/dist/${target}/`,
publicPath: `/dist/web/`,

from loadable-components.

gregberge avatar gregberge commented on August 10, 2024

I think your fix is right, but be careful hash could diverge. Another fix would be to expose node directory client side.

from loadable-components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.