abderrahmen abderrahmen - 1 year ago 78
React JSX Question

make composed Link with react-router

the problem is when I add a composed link for example

<Route path="L1/L2" component={Comp}/>

when navigating to the Link the app can't Load the resources from public folder cause the app is loading the resources from example :
instead of

I guess it's a problem in the webpack configuration but couldn't fix it
here is my webpack config :

var config = {
devtool: 'eval-source-map',
entry: __dirname + "/app/Index.js",
output: {
path: __dirname + "/public",
filename: "bundle.js"
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015','react']
devServer: {
contentBase: "./public",
colors: true,
historyApiFallback: true,
inline: true

all help will be appreciated thank you in advance !

Answer Source

It's about how you load in your bundle in the index.html:

  • <script src="bundle.js"></script> is relative to the current url.

  • <script src="/bundle.js"></script> is relative to the root.

Try the second version, it should work then.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download