Skip to content

Commit

Permalink
remove firstRender logic from Command.Empty, fixes #149
Browse files Browse the repository at this point in the history
  • Loading branch information
pacocoursey committed Jan 30, 2024
1 parent 54aa261 commit be4388e
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions cmdk/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -877,14 +877,9 @@ const Dialog = React.forwardRef<HTMLDivElement, DialogProps>((props, forwardedRe
* Automatically renders when there are no results for the search query.
*/
const Empty = React.forwardRef<HTMLDivElement, EmptyProps>((props, forwardedRef) => {
const isFirstRender = React.useRef(true)
const render = useCmdk((state) => state.filtered.count === 0)

React.useEffect(() => {
isFirstRender.current = false
}, [])

if (isFirstRender.current || !render) return null
if (!render) return null
return <Primitive.div ref={forwardedRef} {...props} cmdk-empty="" role="presentation" />
})

Expand Down

0 comments on commit be4388e

Please sign in to comment.