<commit_before>
const React = require('react');
const { StyleSheet } = require('react-native');

const gStyles = exports.default = {

    title: {
        fontSize: 19,
        fontWeight: 'bold',
        textAlign: 'center'
    },
    duck: {
        height: 320,
        width: 320
    }

};

if (module.hot) {
    module.hot.accept(() => {
        // const nextRootReducer = require('../reducers/index').default;
        // store.replaceReducer(nextRootReducer);
    });
}

exports.compose = (...stylesToCompose) => {

    return StyleSheet.create(Object.assign({},
        gStyles,
        ...stylesToCompose
    ))
}

exports.addStyleHelpers = (Component, ...stylesToCompose) => {

    let hocStyles = exports.compose(...stylesToCompose);

    return class StylishComponent extends React.PureComponent {

        componentWillReceiveProps({ style }) {

            hocStyles = exports.compose(style || {}, ...stylesToCompose);
            // To give passed-in styles the last say in style cascading:
            // hocStyles = exports.compose(...stylesToCompose, style || {});
        }
        render() {

            return <Component {...this.props} style={hocStyles} />;
        }
    }
}<commit_msg>Keep passed-in styles in state in addStyleHelpers<commit_after>
const React = require('react');
const { StyleSheet } = require('react-native');

const gStyles = exports.default = {

    title: {
        fontSize: 19,
        fontWeight: 'bold',
        textAlign: 'center'
    },
    duck: {
        height: 320,
        width: 320
    }

};

if (module.hot) {
    module.hot.accept(() => {
        // const nextRootReducer = require('../reducers/index').default;
        // store.replaceReducer(nextRootReducer);
    });
}

exports.compose = (...stylesToCompose) => {

    return StyleSheet.create(Object.assign({},
        gStyles,
        ...stylesToCompose
    ))
}


exports.addStyleHelpers = (Component, ...stylesToCompose) => {

    return class StylishComponent extends React.PureComponent {

        constructor(props) {

            super(props);

            this.state = {
                hocStyles: exports.compose(props.style || {}, ...stylesToCompose)
            }
        }

        componentWillReceiveProps(nextProps) {

            if (nextProps.style) {
                this.setState((prevState, props) => ({
                    hocStyles: exports.compose(prevState.style || {}, ...stylesToCompose, nextProps.style)
                }));
            }
        }
        render() {

            return <Component {...this.props} style={this.state.hocStyles} />;
        }
    }
}
{'fraction_non_alphanumeric': 0.14499424626006904, 'fraction_numerical': 0.006137322593018795, 'mean_word_length': 2.0396270396270397, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '766978', 'n_tokens_mistral': 796, 'n_tokens_neox': 755, 'n_words': 138}