Skip to content

Change recommended React Router usage in Dropdowns #3720

@Venefilyn

Description

@Venefilyn

Right now, in Dropdown docs we recommend using

<DropdownItem key="link">
  <Link to={'/'}>Link</Link>
</DropdownItem>

Since this by default will create nested <a> we will get an error. On top of that there will also be applied global link styling.

One way we could fix this is by using hooks.

const history = useHistory();
//...

<DropdownItem key="link" onClick={() => history.push("/")}>
  Link
</DropdownItem>

And for class-based usage we can recommend usage from this StackOverflow answer. That way we can use it the same way with onClick as shown above.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions