forked from ColumbusLabs/DebtLens
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhostComponents.ts
More file actions
57 lines (56 loc) · 1.42 KB
/
Copy pathhostComponents.ts
File metadata and controls
57 lines (56 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Built-in UI primitives that are PascalCase but are *not* user-defined child
* components. Forwarding props to these (e.g. `onPress` to a `Pressable`, `style` to a
* `View`) is ordinary composition, not prop drilling. Covers React Native core plus the
* common icon/gradient/blur libraries used across the RN/Expo ecosystem.
*/
export const HOST_COMPONENTS = new Set<string>([
// React Native core
"View",
"Text",
"Image",
"ImageBackground",
"ScrollView",
"FlatList",
"SectionList",
"VirtualizedList",
"Pressable",
"TouchableOpacity",
"TouchableHighlight",
"TouchableWithoutFeedback",
"TouchableNativeFeedback",
"TextInput",
"Switch",
"Modal",
"ActivityIndicator",
"Button",
"RefreshControl",
"StatusBar",
"SafeAreaView",
"KeyboardAvoidingView",
"Animated",
// Common ecosystem libraries
"LinearGradient",
"BlurView",
"MaterialIcons",
"MaterialCommunityIcons",
"Ionicons",
"Feather",
"FontAwesome",
"FontAwesome5",
"AntDesign",
"Entypo",
"Octicons",
"SimpleLineIcons",
"Fontisto",
"Foundation",
"Zocial",
]);
/**
* Returns true if a JSX tag name refers to a host primitive (so it should be ignored
* as a "child component"). Handles namespaced tags like `Animated.View`.
*/
export function isHostComponent(tagName: string): boolean {
const base = tagName.split(".").pop() ?? tagName;
return HOST_COMPONENTS.has(base) || HOST_COMPONENTS.has(tagName);
}