Skip to content

Commit

Permalink
Only render defined props
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlanjc committed Dec 29, 2019
1 parent 69c19b7 commit 7a35d88
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/next/next-server/lib/head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function unique() {
const metaCategories: { [metatype: string]: Set<string> } = {}

return (h: React.ReactElement<any>) => {
if (Object.values(h.props).includes(undefined)) return
let unique = true

if (h.key && typeof h.key !== 'number' && h.key.indexOf('$') > 0) {
Expand Down Expand Up @@ -141,8 +140,11 @@ function reduceComponents(
.filter(unique())
.reverse()
.map((c: React.ReactElement<any>, i: number) => {
const key = c.key || i
return React.cloneElement(c, { key })
let props: { [key: string]: any } = { key: c.key || i }
Object.entries(c.props).forEach(([key, val]) => {
if (![val, typeof val].includes('undefined')) props[key] = val
})
return React.cloneElement(c, props)
})
}

Expand Down

0 comments on commit 7a35d88

Please sign in to comment.