Skip to content

LinkContainer requires pathname in 'to' object. Link does not. #299

Closed
@agawley

Description

@agawley

The following code will cause a runtime error:

<LinkContainer to={{ search: updateSortSearchParams('hi') }}>
    <Dropdown.Item>
       hi
    </Dropdown.Item>
</LinkContainer>

Whereas this will not

<LinkContainer to={{ path: '', search: updateSortSearchParams('hi') }}>
    <Dropdown.Item>
       hi
    </Dropdown.Item>
</LinkContainer>

This is not the same behaviour as <Link /> which happily accepts a search-only 'to' object

Seems like this code in LinkContainer.js should handle undefined pathname

var path = _typeof(to) === 'object' ? to.pathname : to;

Activity

agawley

agawley commented on May 19, 2022

@agawley
ContributorAuthor

The issue (I think) is that later on this path gets passed to matchPath which barfs on undefined

linked a pull request that will close this issueEnable empty pathname and state propagation #303on Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      LinkContainer requires pathname in 'to' object. Link does not. · Issue #299 · react-bootstrap/react-router-bootstrap