vitalets / react-native-extended-stylesheet

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

Styles returns empty Object #34

Closed damathryx closed 7 years ago

damathryx commented 7 years ago

I have a styles.js file and themes/default.js theme.

in styles.js:

import { Platform } from 'react-native';
import EStyleSheet from 'react-native-extended-stylesheet';
import theme from './themes/default';

const styles = EStyleSheet.create({
  PrimaryButton: {
    backgroundColor: 'lightblue',
    borderColor: 'lightblue',
    borderRadius: 0,
  },
  Badge: {
    borderRadius: 5,
    backgroundColor: '#ffc900',
    paddingHorizontal: 5,
    paddingVertical: 2,
    alignSelf: 'center'
  },
  LabelWithBadgeSpaceBetween: {
    justifyContent: 'space-between',
    flexDirection: 'row',
    paddingVertical: 5,
    paddingHorizontal: 10,
    backgroundColor: '#eee'
  },
  AlertButton: {
    backgroundColor: '$alertColor',
    borderColor: '$alertColor',
    borderRadius: 0,
    marginTop: 4,
    marginBottom: 0,
  },
});
EStyleSheet.build(theme);

export default styles;

this returns an empty Object {}. react-native: 0.42.3

damathryx commented 7 years ago

my stupid mistake.

vitalets commented 7 years ago

never mind! :)

yray commented 7 years ago

@damathryx do you mind what kind of mistakes did you do? Looks like I did the same thing to you lol

simonghales commented 7 years ago

@yray Not sure if this will fix your issue, but I was having the same issue just now, I checked the readme instructions and realised I'd forgotten to follow the first step

Import EStyleSheet and call EStyleSheet.build() in entry point of your app:

vitalets commented 7 years ago

Thank you @yray ! I think I will highlight it in readme.