Why query params are disappearing from the url?

Viewed 1375

My React app is using react-router-dom@4.3.1.

This is how I add search after checkbox is clicked:

this.props.history.push({search: `?packages=${list.join(',')}`})

As soon as I click the checkbox, queryparam would display for a split second and disappear. UI does appear corresponding to the queryparams.

What could be the reason it is disappearing?

1 Answers

I think you need to provide pathname as well, path is required

Do it as this

this.props.history.push({pathname: '/yourpath', search: `?packages=${list.join(',')}`})

Hope it helps

Related