react-bootstrap/react-router-bootstrap

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

eugeneborodkin opened this issue · 0 comments

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