Initial commit — Singular Particular Space v1
Homepage (site/index.html): integration-v14 promoted, Writings section integrated with 33 pieces clustered by type (stories/essays/miscellany), Writings welcome lightbox, content frame at 98% opacity. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
61
skills/react-native-skills/rules/ui-pressable.md
Normal file
61
skills/react-native-skills/rules/ui-pressable.md
Normal file
@@ -0,0 +1,61 @@
|
||||
---
|
||||
title: Use Pressable Instead of Touchable Components
|
||||
impact: LOW
|
||||
impactDescription: modern API, more flexible
|
||||
tags: ui, pressable, touchable, gestures
|
||||
---
|
||||
|
||||
## Use Pressable Instead of Touchable Components
|
||||
|
||||
Never use `TouchableOpacity` or `TouchableHighlight`. Use `Pressable` from
|
||||
`react-native` or `react-native-gesture-handler` instead.
|
||||
|
||||
**Incorrect (legacy Touchable components):**
|
||||
|
||||
```tsx
|
||||
import { TouchableOpacity } from 'react-native'
|
||||
|
||||
function MyButton({ onPress }: { onPress: () => void }) {
|
||||
return (
|
||||
<TouchableOpacity onPress={onPress} activeOpacity={0.7}>
|
||||
<Text>Press me</Text>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
**Correct (Pressable):**
|
||||
|
||||
```tsx
|
||||
import { Pressable } from 'react-native'
|
||||
|
||||
function MyButton({ onPress }: { onPress: () => void }) {
|
||||
return (
|
||||
<Pressable onPress={onPress}>
|
||||
<Text>Press me</Text>
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
**Correct (Pressable from gesture handler for lists):**
|
||||
|
||||
```tsx
|
||||
import { Pressable } from 'react-native-gesture-handler'
|
||||
|
||||
function ListItem({ onPress }: { onPress: () => void }) {
|
||||
return (
|
||||
<Pressable onPress={onPress}>
|
||||
<Text>Item</Text>
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
Use `react-native-gesture-handler` Pressable inside scrollable lists for better
|
||||
gesture coordination, as long as you are using the ScrollView from
|
||||
`react-native-gesture-handler` as well.
|
||||
|
||||
**For animated press states (scale, opacity changes):** Use `GestureDetector`
|
||||
with Reanimated shared values instead of Pressable's style callback. See the
|
||||
`animation-gesture-detector-press` rule.
|
||||
Reference in New Issue
Block a user