|
| 1 | +import * as React from 'react'; |
| 2 | +import { SafeAreaView, ScrollView, StyleSheet, Text } from 'react-native'; |
| 3 | +import { Select } from '@mobile-reality/react-native-select-pro'; |
| 4 | + |
| 5 | +const data = [ |
| 6 | + { |
| 7 | + label: 'Option 1', |
| 8 | + value: 'option1', |
| 9 | + }, |
| 10 | + { |
| 11 | + label: 'Option 2', |
| 12 | + value: 'option2', |
| 13 | + }, |
| 14 | + { |
| 15 | + label: 'Option 3', |
| 16 | + value: 'option3', |
| 17 | + }, |
| 18 | + { |
| 19 | + label: 'Option 4', |
| 20 | + value: 'option4', |
| 21 | + }, |
| 22 | +]; |
| 23 | + |
| 24 | +export const ScrollViewExample = () => { |
| 25 | + return ( |
| 26 | + <SafeAreaView style={styles.safeArea}> |
| 27 | + <ScrollView style={styles.scrollView}> |
| 28 | + <Text style={styles.title}> |
| 29 | + When using ScrollView together with Select, there are two key things to keep in |
| 30 | + mind. |
| 31 | + </Text> |
| 32 | + |
| 33 | + <Text style={styles.paragraph}> |
| 34 | + First, the SelectProvider must be placed above the ScrollView in the component |
| 35 | + hierarchy. |
| 36 | + </Text> |
| 37 | + |
| 38 | + <Text style={styles.paragraph}> |
| 39 | + In our case, the SelectProvider is located in the parent component, App. |
| 40 | + </Text> |
| 41 | + |
| 42 | + <Text style={styles.paragraph}> |
| 43 | + Second, it is important to ensure that SelectProvider is not duplicated across |
| 44 | + different parts of the application. |
| 45 | + </Text> |
| 46 | + |
| 47 | + <Text style={styles.paragraph}> |
| 48 | + This can cause issues with calculating the position of the dropdown menu. |
| 49 | + </Text> |
| 50 | + <Select options={data} /> |
| 51 | + <Text style={styles.paragraph}>Scroll View Example</Text> |
| 52 | + <Text style={styles.paragraph}>Scroll View Example</Text> |
| 53 | + <Text style={styles.paragraph}>Scroll View Example</Text> |
| 54 | + <Select options={data} /> |
| 55 | + <Text style={styles.paragraph}>Scroll View Example</Text> |
| 56 | + <Text style={styles.paragraph}>Scroll View Example</Text> |
| 57 | + <Text style={styles.paragraph}>Scroll View Example</Text> |
| 58 | + <Select options={data} /> |
| 59 | + <Text style={styles.paragraph}>Scroll View Example</Text> |
| 60 | + <Text style={styles.paragraph}>Scroll View Example</Text> |
| 61 | + <Text style={styles.paragraph}>Scroll View Example</Text> |
| 62 | + </ScrollView> |
| 63 | + </SafeAreaView> |
| 64 | + ); |
| 65 | +}; |
| 66 | + |
| 67 | +const styles = StyleSheet.create({ |
| 68 | + title: { |
| 69 | + fontSize: 20, |
| 70 | + fontWeight: 'bold', |
| 71 | + textAlign: 'center', |
| 72 | + }, |
| 73 | + paragraph: { |
| 74 | + margin: 24, |
| 75 | + textAlign: 'center', |
| 76 | + }, |
| 77 | + safeArea: { |
| 78 | + flex: 1, |
| 79 | + }, |
| 80 | + scrollView: { |
| 81 | + flex: 1, |
| 82 | + padding: 25, |
| 83 | + }, |
| 84 | +}); |
0 commit comments