react-native APIs
- View
- StyleSheet
- Text
- Platform
- TouchableOpacity
- ScrollView
- Image
- ViewStyle
- Dimensions
- StatusBar
- TextInput
- FlatList
- SafeAreaView
- TextStyle
- ActivityIndicator
- Alert
- StyleProp
- Animated
- Linking
- TouchableWithoutFeedback
- Button
- NativeModules
- KeyboardAvoidingView
- TextInputProps
- ViewProps
- Keyboard
- Easing
- ImageBackground
- TextProps
- LayoutChangeEvent
- NativeSyntheticEvent
- NativeEventEmitter
- Switch
- AppRegistry
- ImageStyle
- ImageSourcePropType
- TouchableOpacityProps
- Modal
- AppState
- RefreshControl
- TouchableHighlight
- BackHandler
- useWindowDimensions
- GestureResponderEvent
- AppStateStatus
- PixelRatio
- useColorScheme
- SectionList
- Pressable
- AsyncStorage
- UIManager
- I18nManager
- ImageProps
- LogBox
- FlatListProps
- LayoutRectangle
- findNodeHandle
- EmitterSubscription
- requireNativeComponent
- PermissionsAndroid
- InteractionManager
- ScrollViewProps
- TextInputFocusEventData
- Share
- ColorSchemeName
- ScaledSize
- Clipboard
- Insets
- NativeScrollEvent
- ListRenderItem
- LayoutAnimation
- TouchableNativeFeedback
- PanResponder
- SectionListData
- ListRenderItemInfo
- AccessibilityRole
- AccessibilityInfo
- ImageURISource
- ViewToken
- SectionListProps
- DeviceEventEmitter
- KeyboardEvent
- ActionSheetIOS
- processColor
- YellowBox
- DevSettings
- Slider
- ViewabilityConfig
- AccessibilityState
- EventSubscription
- Permission
- TextInputSelectionChangeEventData
- EasingFunction
- TouchableHighlightProps
- TextInputSubmitEditingEventData
- TextInputChangeEventData
- Appearance
- KeyboardTypeOptions
- AccessibilityEvent
- NativeScrollPoint
- ActionSheetIOSOptions
- HostComponent
- PlatformOSType
- ITheme
- IThemeColors
- IThemeFonts
- IThemeLayout
- IThemeUtils
- ViewPropTypes
- SectionListRenderItem
- NativeAppEventEmitter
- Picker
- VirtualizedList
- SectionListRenderItemInfo
- TextInputKeyPressEventData
- ShareAction
- ImageErrorEventData
- ProgressViewIOS
- ProgressBarAndroid
- RotateXTransform
- RotateYTransform
- PerpectiveTransform
- RotateTransform
- RotateZTransform
- ScaleTransform
- ScaleXTransform
- ScaleYTransform
- TranslateXTransform
- TranslateYTransform
- SkewXTransform
- SkewYTransform
- TransformsStyle
- NativeModulesStatic
- CheckBox
Other Related APIs
- react#ComponentClass
- react-native#View
- react-native#Text
- react-native#StyleSheet
- react-native#StyleProp
- react-native#TextStyle
- react-native#ViewStyle
- react-native#TouchableOpacityProps
- react-native#TextInputProps
- react-native#ViewProps
- react-native#TextProps
- react-native#ActivityIndicator
- react-native#ScrollViewProps
- react-native#ImageSourcePropType
- react-native#ImageProps
- react-native#SectionListProps
- react-native#FlatListProps
react-native#TouchableHighlightProps TypeScript Examples
The following examples show how to use
react-native#TouchableHighlightProps.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Checkbox.tsx From react-native-jigsaw with MIT License | 4 votes |
Checkbox: React.FC<CheckboxProps & TouchableHighlightProps & IconSlot> =
({
Icon,
status,
disabled = false,
onPress,
onCheck,
onUncheck,
color,
uncheckedColor,
defaultValue,
checkedIcon = "MaterialCommunityIcons/checkbox-marked",
uncheckedIcon = "MaterialCommunityIcons/checkbox-blank-outline",
size = 24,
style,
...rest
}) => {
const [internalValue, setInternalValue] = React.useState<boolean>(
status || defaultValue || false
);
React.useEffect(() => {
if (status != null) {
setInternalValue(status);
}
}, [status]);
// This special logic is to handle weird APIs like Airtable that return
// true or undefined for a boolean
const previousDefaultValue = usePrevious(defaultValue) as
| boolean
| undefined;
React.useEffect(() => {
if (defaultValue !== previousDefaultValue) {
setInternalValue(Boolean(defaultValue));
}
}, [defaultValue, previousDefaultValue]);
const { colors } = useTheme();
const checkboxColor = internalValue
? color || colors.primary
: uncheckedColor || colors.primary;
const handlePress = () => {
const newValue = !internalValue;
setInternalValue(newValue);
onPress?.(newValue);
if (newValue) {
onCheck?.();
}
if (!newValue) {
onUncheck?.();
}
};
return (
<Touchable
{...rest}
onPress={handlePress}
disabled={disabled}
accessibilityState={{ disabled }}
accessibilityRole="button"
accessibilityLiveRegion="polite"
style={[styles.container, style, { width: size, height: size }]}
>
<Icon
style={styles.icon}
name={internalValue ? checkedIcon : uncheckedIcon}
size={size}
color={checkboxColor}
/>
<View style={[StyleSheet.absoluteFill, styles.fillContainer]}>
<View
style={[
styles.fill,
{ opacity: disabled ? 0.5 : 1 },
{ borderColor: checkboxColor },
]}
/>
</View>
</Touchable>
);
}