From fe8c181a4b6a454a98d65d45bcda521c72f5ef81 Mon Sep 17 00:00:00 2001 From: Mark Lawlor Date: Thu, 26 May 2022 10:58:19 +1000 Subject: [PATCH] fix: runtime error with RNW <=0.17 --- src/runtime-styles.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/runtime-styles.ts b/src/runtime-styles.ts index 18bfe22..09034ed 100644 --- a/src/runtime-styles.ts +++ b/src/runtime-styles.ts @@ -1,4 +1,4 @@ -import { ViewStyle } from "react-native"; +import { ViewStyle, StyleSheet } from "react-native"; import { ComponentContext, TailwindContext } from "./context"; import { matchAtRule } from "./match-at-rule"; import { normaliseSelector } from "./shared/selector"; @@ -85,8 +85,16 @@ export function getRuntimeStyles

({ } } - const { transform, ...style } = styleRecord; + // For RWN <=0.17 we need to convert the styleID into an object to handle + // merging transform. + // + // This is a performance issue, but hopefully move people will move onto + // RWN 0.18 and use CSS + if (typeof styleRecord === "number") { + styleRecord = StyleSheet.flatten(styleRecord); + } + const { transform, ...style } = styleRecord; tailwindStyles.push(style as P); if (transform) {