vitalets / react-native-extended-stylesheet

Extended StyleSheets for React Native
MIT License
2.93k stars 132 forks source link

rem usage breaks styles in RN 62 w TypeScript #138

Closed mutablestudio closed 4 years ago

mutablestudio commented 4 years ago

Hello - not sure if I'm doing something wrong or if the issue is TypeScript but when I try to use rem in EStyleSheet.create the view using the style will not render and nothing after it will render either. When I change to 34 instead of '34rem' it will render properly.

const styles = EStyleSheet.create({
  title: {
    fontSize: '34rem',
    color: Colors.white,
  },

I'm also trying to use EStyleSheet.build in App.tsx to set a global $rem def but this doesn't seem to fix the issue.

const rem = width / (Platform.OS === 'ios' ? 375 : 0.95)

EStyleSheet.build({
  $rem: rem,
  $backgroundColor: Colors.primaryBlueColor,
})

Any ideas if this is typescript related? I have it working in a different project that's not using TS...

Environment

mutablestudio commented 4 years ago

I moved EStyleSheet.build to index.js and this fixed the issue