Skip to content

Commit 16c3a16

Browse files
committed
fix(dropdown): renames imported theme in Dropdown to avoid confusion with theme in Dropdown props
This fixes the way theme is imported in Dropdown. `theme` is alredy defined in Dropdown's props and lead to confusion. This also changes how `useColorScheme` is used.
1 parent 6a4348a commit 16c3a16

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Dropdown.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ListRenderItem } from 'react-native'
33
import { StyleSheet, FlatList, View, useColorScheme } from 'react-native'
44
import * as Animatable from 'react-native-animatable'
55
import { fadeInDownShort, fadeInUpShort } from './helpers'
6-
import { theme } from './theme'
6+
import { theme as defaultTheme } from './theme'
77
import type { AutocompleteDropdownItem, IAutocompleteDropdownProps } from './types'
88
interface DropdownProps extends Omit<IAutocompleteDropdownProps, 'renderItem' | 'ref'> {
99
ListEmptyComponent: React.ReactElement
@@ -21,7 +21,8 @@ export const Dropdown = memo((props: DropdownProps) => {
2121
theme,
2222
...rest
2323
} = props
24-
const themeName = theme || useColorScheme()
24+
const systemTheme = useColorScheme()
25+
const themeName = theme || systemTheme
2526
const styles = useMemo(() => getStyles(themeName || 'light'), [themeName])
2627

2728
const defaultItemSeparator = useMemo(() => {
@@ -59,11 +60,11 @@ const getStyles = (themeName: 'light' | 'dark' = 'light') =>
5960
StyleSheet.create({
6061
container: {},
6162
listContainer: {
62-
backgroundColor: theme[themeName].suggestionsListBackgroundColor,
63+
backgroundColor: defaultTheme[themeName].suggestionsListBackgroundColor,
6364
width: '100%',
6465
zIndex: 9,
6566
borderRadius: 5,
66-
shadowColor: theme[themeName || 'light'].shadowColor,
67+
shadowColor: defaultTheme[themeName || 'light'].shadowColor,
6768
shadowOffset: {
6869
width: 0,
6970
height: 12,
@@ -76,6 +77,6 @@ const getStyles = (themeName: 'light' | 'dark' = 'light') =>
7677
itemSeparator: {
7778
height: 1,
7879
width: '100%',
79-
backgroundColor: theme[themeName || 'light'].itemSeparatorColor,
80+
backgroundColor: defaultTheme[themeName || 'light'].itemSeparatorColor,
8081
},
8182
})

0 commit comments

Comments
 (0)