React: update URL with id from Select

Viewed 17

I have the following component (it is just some wrapper on Select and inside this Component most of properties are assigned to <Select> component):

        <FormSelectNative
            options={games}
            valueKey="id"
            labelKey="name"
            onChange={handleGameSelect}
            defaultValue={games[0].id}
          />

And here is handleGameSelect method that is run onChange Select event. It loads data new data.

 const handleGameSelect = event => {
    axios.get(`/games/${event.target.value}`).then(function (response) {
      const { game, backgrounds, categories } = response.data;
      setData({ game, backgrounds, categories });
    });
  };

There is no page reload here. I need to update Url with {event.target.value} value. So that when user will press Refresh or Copy link, he will be able to navigate to the same data.

But not sure how to do this?

0 Answers
Related