Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eugeneborodkin opened this issue Aug 30, 2021 · 0 comments
Open

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

eugeneborodkin opened this issue Aug 30, 2021 · 0 comments

Comments

@eugeneborodkin
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant