eslint-plugin-react-native icon indicating copy to clipboard operation
eslint-plugin-react-native copied to clipboard

Unused style detected warning when using object destructuring

Open MaxNoack opened this issue 4 years ago • 0 comments

We using destructuring on your StyleSheet.create object you get a "Unused style detected" warning, even though the style is in use. Example:

//This gives no warning
const styles = StyleSheet.create({
  name: {}
});

const Hello = React.createClass({
  render: function() {
    return <Text style={styles.name}>Hello</Text>;
  }
});
//This gives a warning
const { name } = StyleSheet.create({
  name: {}
});

const Hello = React.createClass({
  render: function() {
    return <Text style={name}>Hello</Text>;
  }
});

Excepted behavior should be to pass both versions.

MaxNoack avatar Nov 09 '20 07:11 MaxNoack