Skip to content

Commit

Permalink
Use StyleSheet.create in React Native
Browse files Browse the repository at this point in the history
  • Loading branch information
efoken committed Oct 30, 2020
1 parent 6e157aa commit 3c46c7a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/primitives-core/src/css.js
Expand Up @@ -7,6 +7,7 @@ import { interleave } from './utils'
// this is done so we don't create a new
// handleInterpolation function on every css call
let styles
let generated = {}
let buffer = ''
let lastType

Expand Down Expand Up @@ -102,7 +103,12 @@ export function createCss(StyleSheet: Object) {
buffer = prevBuffer
}

return StyleSheet.flatten(styles)
const hash = JSON.stringify(styles)
if (!generated[hash]) {
const styleSheet = StyleSheet.create({ generated: styles })
generated[hash] = styleSheet.generated
}
return generated[hash]
}
}

Expand Down

0 comments on commit 3c46c7a

Please sign in to comment.