The problem of passing parameters with special characters in react-router

when the passed parameter contains? (question mark), the value obtained by using this.props.match.params is not desired, because at this time? (question mark) is regarded as the query string (querystring), how to deal with this situation?

/:id  id"12?34",this.props.match.params.id12"12?34"
Mar.23,2021

encodeURIComponent
then go to decodeURIComponent


you can try a very short and useful library: query-string .

const queryString = require('query-string');
 
console.log(location.search);
//=> '?foo=bar'
 
const parsed = queryString.parse(location.search);
console.log(parsed);
//=> {foo: 'bar'}
 
console.log(location.hash);
//=> '-sharptoken=bada55cafe'
 
const parsedHash = queryString.parse(location.hash);
console.log(parsedHash);
//=> {token: 'bada55cafe'}
 
parsed.foo = 'unicorn';
parsed.ilike = 'pizza';
 
const stringified = queryString.stringify(parsed);
//=> 'foo=unicorn&ilike=pizza'
 
location.search = stringified;
// note that `location.search` automatically prepends a question mark
console.log(location.search);
//=> '?foo=unicorn&ilike=pizza'
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9ac79-1801.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9ac79-1801.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?