-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathfunctionalStylesExample.tsx
More file actions
37 lines (35 loc) · 805 Bytes
/
functionalStylesExample.tsx
File metadata and controls
37 lines (35 loc) · 805 Bytes
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
import React from 'react';
import { PressableStateCallbackType, StyleSheet, View } from 'react-native';
import TestingBase from './testingBase';
export function FunctionalStyleExample() {
const functionalStyle = (state: PressableStateCallbackType) => {
if (state.pressed) {
return {
width: 100,
height: 100,
backgroundColor: 'red',
};
} else {
return {
width: 100,
height: 100,
backgroundColor: 'mediumpurple',
};
}
};
return (
<View style={styles.container}>
<TestingBase style={functionalStyle} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
gap: 40,
padding: 20,
},
});