Skip to content

no-unused-styles doesn't support conditional styles #125

Open
@robcalcroft

Description

@robcalcroft

I often add conditional styles to my components and no-unused-styles doesn't see that the style is actually used in the code.

const styles = StyleSheet.create({
  container: {
    padding: 1,
  },
  'container--critical': {
    backgroundColor: MY_RED_CONST,
  },
});

const Component = ({ shouldBeRed }) => (
  <View style={[styles.container].concat(shouldBeRed ? styles['container--critical'] : [])}>
    <Text>This is some text</Text>
  </View>
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions