1

I am using react router 4 and when some checkboxes are checked I want to update the current url with the values from the checkbox.

How can I push parameters to the current url? Also if possible I don't really want to support it that if they click the back button it would uncheck the last option (unless I pretty much get this functionality for free).

So I am thinking it would have to be more a replacement of the url rather that push.

1 Answer 1

2

Install history package from npm

Create a new file config/history.js

import createHistory from 'history/createBrowserHistory';
export default createHistory();

Now in your code where you wanted to update the url, use the following:

import history from './config/history';

....
<input type="checkbox" onChange={() => history.push('/foo?variable=value') } />
Sign up to request clarification or add additional context in comments.

1 Comment

history.replace(url) seems to better fit the question (instead of history.push(url))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.