Skip to content

Commit

Permalink
Fix forceMount too many rerenders (#143)
Browse files Browse the repository at this point in the history
* Fix forceMount too many rerenders

* fix format

---------

Co-authored-by: João Pedro Magalhães <[email protected]>
  • Loading branch information
joaom00 and João Pedro Magalhães authored Jan 30, 2024
1 parent e97839f commit b768f2b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmdk/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,10 @@ const Item = React.forwardRef<HTMLDivElement, ItemProps>((props, forwardedRef) =
const forceMount = propsRef.current?.forceMount ?? groupContext?.forceMount

useLayoutEffect(() => {
return context.item(id, groupContext?.id)
}, [])
if (!forceMount) {
return context.item(id, groupContext?.id)
}
}, [forceMount])

const value = useValue(id, ref, [props.value, props.children, ref])

Expand Down

0 comments on commit b768f2b

Please sign in to comment.