Skip to content

Commit

Permalink
fix(cache): fix object keys caching (#383)
Browse files Browse the repository at this point in the history
Stringify objects before caching them.
  • Loading branch information
mleralec committed Oct 5, 2022
1 parent c35d470 commit 879708c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/system/src/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ const getStyleFactory = (
const value = props[prop]
if (!is(value)) return null
const cache = getCache<CSSObject | null | undefined>(props.theme, prop)
if (cache.has(value)) return cache.get(value)
const style = fromValue(props[prop])
cache.set(value, style)
const key = obj(value) ? JSON.stringify(value) : value
if (cache.has(key)) return cache.get(key)
const style = fromValue(value)
cache.set(key, style)
return style
}
}
Expand Down

0 comments on commit 879708c

Please sign in to comment.