vitalets / react-native-extended-stylesheet

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

Need to combine Stylesheet in order to create global styles #107

Closed gungdeaditya closed 5 years ago

gungdeaditya commented 5 years ago

Is it possible if we use spread operator to combine stylesheet, because I tried but had no succeed

vitalets commented 5 years ago

Yes, it is possible. Could you show the code how did you try?

edwang2007 commented 5 years ago

I am having the same issue. Note that global styles is meant for only a couple of screens and so would really like to use the spread operator.

import EStyleSheet from 'react-native-extended-stylesheet';
import globalStyles from '../GlobalStyles';

const styles = EStyleSheet.create({
    ...globalStyles,
    container: {
        flex: 1,
    },
});
import EStyleSheet from 'react-native-extended-stylesheet';

const globalStyles = EStyleSheet.create({
    headerContainer: {
        flex: 1,
        alignSelf: 'center',
    },
    headerText: {
        fontSize: '80rem',
    }
});

export default globalStyles;
vitalets commented 5 years ago

hi @edwang2007 !

Is it possible for you app to define global styles as raw object? For example:

GlobalStyles.js

export default {
    headerContainer: {
        flex: 1,
        alignSelf: 'center',
    },
    headerText: {
        fontSize: '80rem',
    }
};

Component.js

import EStyleSheet from 'react-native-extended-stylesheet';
import globalStyles from '../GlobalStyles';

const styles = EStyleSheet.create({
    ...globalStyles,
    container: {
        flex: 1,
    },
});
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.