vitalets / react-native-extended-stylesheet

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

Invalid prop 'width' of type 'string', Expected 'number' #64

Closed harwinvoid closed 6 years ago

harwinvoid commented 7 years ago
import EStyleSheet from 'react-native-extended-stylesheet';

export default EStyleSheet.create({
  container: {
    fontSize: '2rem',
    width: '10%',
  },
});

img_0911

RN version 0.30 ios 11

vitalets commented 7 years ago

Hi! It's because of RN version that does not support percents natively. I will think what we can do. By the way, could you share the reasons why you don't update RN?

Related: https://github.com/vitalets/react-native-extended-stylesheet/issues/32

harwinvoid commented 6 years ago

thank a lot。 the reason is a long story

vitalets commented 6 years ago

Anyway, the workaround can be done by value as a function:

export default EStyleSheet.create({
  container: {
    fontSize: '2rem',
    width: () => 0.1 * Dimensions.get('window').width
  },
});

Feel free to reopen if needed.