getUserConfirmation prop

The getUserConfirmation prop accepts a function as its value, and it's executed when the user-initiated navigation is blocked using the <Prompt> component. The <Prompt> component shows a confirmation dialog box using the window.confirm method, and navigates the user to the selected path only if the user clicks the OK button. However, when the <BrowserRouter> component specifies the getUserConfirmation prop, the function provided as a value to this prop will be executed. This provides an opportunity to display a custom dialog box.

Let's take a look at the following configuration:

<BrowserRouter getUserConfirmation={this.userConfirmationFunc}>    <div className="container">        <nav>            <Link to="/dashboard">Dashboard</Link

Get React Router Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.