Skip to content

LinkContainer to={..} does not read state variable #264

Open
@eugeneborodkin

Description

@eugeneborodkin

Could someone help me?

I have a state variable as follows,

const [searchParams, setSearchParams] = useState(null);

If I have the following reference to it directly via href (let's say from a Bootstrap-React Dropdown component), I verify that it works, and the URL is correct:

<Dropdown.Menu>
    <Dropdown.Item href={"/viewAgreementForm&searchParams" + searchParams}>View</Dropdown.Item>                        
</Dropdown.Menu>

But as soon as I add a LinkContainer around the Dropdown Item with a to={..}, it no longer reads the latest state variable. The value is NULL (perhaps from initialization).

   <Dropdown.Menu>
       <LinkContainer to={"/viewAgreementForm&searchParams=" + searchParams}>
            <Dropdown.Item>View</Dropdown.Item>
       </LinkContainer>
   </Dropdown.Menu>

I get ...&searchParams=null

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