How to parse query string in react-router v4

前端 未结 7 957
孤独总比滥情好
孤独总比滥情好 2020-12-04 16:27

In react-router v3 I could access it with props.location.query.foo (if the current location was ?foo=bar)

In react-router-dom@4.0.0

相关标签:
7条回答
  • 2020-12-04 17:23

    You may get the following error while creating an optimized production build when using query-string module.

    Failed to minify the code from this file: ./node_modules/query-string/index.js:8

    To overcome this, kindly use the alternative module called stringquery which does the same process well without any issues while running the build.

    import querySearch from "stringquery";
    
    var query = querySearch(this.props.location.search);
    

    Thank you.

    0 讨论(0)
提交回复
热议问题