Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Lint error duplicate keys when setting style

How can I avoid having duplicate keys or nested ternarys when setting my style? I need to change the margin for ios and certain iPhones.

import DeviceInfo from 'react-native-device-info';

const devices = ['iPhone 12', 'iPhone 12 Pro', 'iPhone 12 Pro Max'];

const styles = StyleSheet.create({
  container: {
    flexDirection: 'row',
    paddingHorizontal: 20,
    paddingTop: 10,
    marginBottom: Platform.OS === "ios" ? 10 : 0;,
    marginBottom: devices.includes(DeviceInfo.getModel()) ? 30 : 0
  },

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How about this.
marginBottom: (Platform.OS === "ios" && 10) || (devices.includes(DeviceInfo.getModel() && 30 ) || 0;

It may not perfectly fit what you want, but with a little modification it should be possible.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading