Unable to pass props to component through react-router

后端 未结 3 760
予麋鹿
予麋鹿 2020-12-18 15:43

I am unable to pass props using react-router. My code till now:

import React from \'react\';
import ReactDOM from \'react-dom\';
import { BrowserRouter, Rout         


        
相关标签:
3条回答
  • 2020-12-18 16:14

    This is the same problem as in this question. The problem is specific to the setup. As shown in error message, bundle.js is loaded from current path, /edit/bundle.js, while it should be loaded from /bundle.js.

    Scripts should either have absolute paths:

    <script type="text/javascript" src="/bundle.js"></script>
    

    Or base URL should be specified:

    <base href="/">
    
    0 讨论(0)
  • 2020-12-18 16:18

    It may be an issue with your local environment, I dont see anyproblem with your code. I tried out in https://codesandbox.io/s/ox773ywmn9 and there is no issue

    0 讨论(0)
  • 2020-12-18 16:20

    I can access the props in the child components using this:

    this.props.match.params.id
    
    0 讨论(0)
提交回复
热议问题