Skip to content

Link reloads the page if error happens in the onClick handler #6709

@marton-levay

Description

@marton-levay

Version

    "react": "16.8.3",
    "react-dom": "16.8.3",
    "react-redux": "5.0.7",
    "react-router": "5.0.0",
    "react-router-dom": "5.0.0",

Test Case

  • Add any onClick handler to a Link component and make it fail
<Link to="/about"  onClick={() => {throw "up";}}> Click me! </Link>

Example:

https://codesandbox.io/s/yknnw1k959

Steps to reproduce

Add an onClick handler to a Link component which throws any type of exception or error.

Expected Behavior

Not to reload the page so I would have chance to see the error in the console

Actual Behavior

The Link navigates to the desired page but also reloads the page deleting any chance of seeing that an error even happened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions