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

Fix forceMount too many rerenders #143

Merged
merged 3 commits into from
Jan 30, 2024

Conversation

joaom00
Copy link
Contributor

@joaom00 joaom00 commented May 29, 2023

When using the following code to add a "Create action", React throws Maximum update depth exceeded error because filtered.count will loop update between 0 and 1

const search = useCommandState((state) => state.search)
const isEmpty = useCommandState((state) => state.filtered.count === 0)

return isEmpty ? <Command.Item forceMount>Create {search}</Command.Item> : null

To fix this the Item is not registered to be filtered when forceMount is true

@vercel
Copy link

vercel bot commented May 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cmdk-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2023 1:03am

@pacocoursey pacocoursey merged commit b768f2b into pacocoursey:main Jan 30, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants