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

Updating state with useSearchParams on Select component causes multiple reenders #1738

Closed
1 of 3 tasks
juliomuhlbauer opened this issue Nov 17, 2023 · 5 comments
Closed
1 of 3 tasks

Comments

@juliomuhlbauer
Copy link
Contributor

Description

When using Nexjjs's useSearchParams hook with Select component causes multiple reenders.

Link to Reproduction (or Detailed Explanation)

https://use-search-param-ark.vercel.app/search-param

Steps to Reproduce

  1. Go to the reproduction
  2. Open console
  3. Change the select value

Ark UI Version

1.0.0

Framework

  • React
  • Solid
  • Vue

Browser

Chrome

Additional Information

GitHub Repo: https://github.com/juliomuhlbauer/use-search-param-ark

@juliomuhlbauer
Copy link
Contributor Author

2023-11-17.11-06-22.mp4

@juliomuhlbauer
Copy link
Contributor Author

juliomuhlbauer commented Nov 17, 2023

Also, it would be cool seeing an example of integrating Ark and Nextjs with url on state

@segunadebayo
Copy link
Member

I looked into this deeply today and found that it's a Next.js bug

vercel/next.js#43691
vercel/next.js#49881

In the meantime, you can use the good'ol history.pushState

const handleChange = (details) => {
        const params = new URLSearchParams(searchParams)
        params.set('city', value[0])
       // workaround until Next.js fix
        window.history.pushState(
          {},
          '',
          `/search-param?${params.toString()}`
         )
     }
}

@juliomuhlbauer
Copy link
Contributor Author

But how do I read from the url with Nextjs? It would cause hydration problems

@juliomuhlbauer
Copy link
Contributor Author

I opened an issue on Nextjs: vercel/next.js#58684

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

2 participants