Skip to content

Commit

Permalink
fix(docz): optional opts for useMenus()
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Feb 27, 2019
1 parent 8f8ed12 commit 571ffcd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/docz/src/hooks/useMenus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ export interface UseMenusParams {
query?: string
}

export const useMenus = ({ query = '' }: UseMenusParams) => {
export const useMenus = (opts?: UseMenusParams) => {
const { query = '' } = opts || {}
const { entries, config } = useContext(doczState.context)
if (!entries || !config) return null

Expand All @@ -129,5 +130,7 @@ export const useMenus = ({ query = '' }: UseMenusParams) => {
return sortMenus(merged, config.menu)
}, [entries, config])

return query.length > 0 ? (search(query, sorted) as MenuItem[]) : sorted
return query && query.length > 0
? (search(query, sorted) as MenuItem[])
: sorted
}

0 comments on commit 571ffcd

Please sign in to comment.