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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy