Why does the queryString value accumulate behind the url when using a history object in response in react?

38 views Asked by At

first History.push screen

enter image description here

[example code]

const { history } = this.props;
history.push({ pathname: 'workspace?task=14' });

Result URL

enter image description here

[example result]

Chrome URL => http://localhost3000/workspace?task=14

but ... If I send another request here...

next use History.push

enter image description here

[example code]

history.push('workspace?task=15');

next use History push result URL

enter image description here

[example result]

Chrome URL => http:// localhost3000/workspace?task=14?task=15

It overlaps...

No matter how hard I look, I can't find the results. Please help me.

1

There are 1 answers

0
JiwoonJung On

I solved this problem simply. My basic skills are too lacking. In conclusion, the query string value should not be put in the patch name, but it was solved when it was put in the key search. I think I studied a lot. I worked hard for 4 hours with just this.

before

history.push({pathname: `workspace?task=14`});

after

history.push({pathname: `workspace` , search: `task=14`})