1// As far as I know there are three methods you can do that.
2// Suppose an URL looks like this
3// http://www.google.com.au?token=123
4
5// 1) use a third library called 'query-string'.
6import queryString from 'query-string'
7
8const value=queryString.parse(this.props.location.search);
9const token=value.token;
10console.log('token',token)//123
11
12// 2) Without library - Get a single query string
13const query = new URLSearchParams(this.props.location.search);
14
15const token = query.get('token')
16console.log(token)//123
17
18// 3) One liner - Get query string with '&' and without any library
19const getQueryParams = () => window.location.search.replace('?', '').split('&').reduce((r,e) => (r[e.split('=')[0]] = decodeURIComponent(e.split('=')[1]), r), {});