Skip to content

Commit

Permalink
Fix component for older Android versions
Browse files Browse the repository at this point in the history
@mjmasn 😱
  • Loading branch information
pederjohnsen authored Mar 15, 2019
1 parent 57887aa commit cafe27c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/chip/Chip.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow strict-local
import {isFunction, isString} from 'lodash-es';
import * as React from 'react';
import {LayoutAnimation, StyleSheet, TouchableNativeFeedback, View} from 'react-native';
import {Platform, LayoutAnimation, StyleSheet, TouchableNativeFeedback, View} from 'react-native';

import {Icon} from '../icon';
import {withTheme, type ThemeProps} from '../theme';
Expand Down Expand Up @@ -138,8 +138,17 @@ class Chip extends React.PureComponent<Props> {
render() {
const {highlighted, icon, label, outline, selected, thumbnail, rctshtTheme} = this.props;

// eslint-disable-next-line babel/new-cap
const background = TouchableNativeFeedback.SelectableBackgroundBorderless();
let background = null;

if (Platform.OS === 'android') {
if (Platform.Version >= 21) {
// eslint-disable-next-line babel/new-cap
background = TouchableNativeFeedback.SelectableBackgroundBorderless();
} else {
// eslint-disable-next-line babel/new-cap
background = TouchableNativeFeedback.SelectableBackground();
}
}

const thumb = thumbnail != null ? <View style={styles.thumbnailWrapper}>{thumbnail}</View> : null;
const selectedIndicator = selected ? (
Expand Down

0 comments on commit cafe27c

Please sign in to comment.