How to trigger react-router-dom prompt from a function

On page change or reload or close, react-router-dom prompt is displaying; however, in my page I am using Material UI tabs and I want the prompt to display on tab change as well.

This is the code for my prompt.

    <Prompt
      when={valueChanged}
      message={"Are you sure you want to leave?"}
    />

The prompt only displays if I change in the route or close the browser or reload, but how can I make it display without having to change the route (when a change happens on the same page).