Skip to content

Commit

Permalink
feat: improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam committed Jun 15, 2022
1 parent e6cdd64 commit 91e78bb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/NativePicker.tsx
Expand Up @@ -7,7 +7,7 @@ import {
} from 'react-native';
import type {
NativeColorType,
NativeOnChangeEvent,
NativeOnChange,
NativePickerDataItem,
} from './types';

Expand All @@ -19,7 +19,7 @@ type NativeAndroidData = NativePickerDataItem;
type NativeCommonProps = {
loop?: boolean;
data: NativeIOSData | NativeAndroidData;
onChange?: NativeOnChangeEvent;
onChange?: NativeOnChange;
};

type NativeIOSProps = {
Expand All @@ -41,8 +41,7 @@ type NativeAndroidProps = {
};

export type NativePickerProps = NativeCommonProps &
NativeIOSProps &
NativeAndroidProps;
(NativeIOSProps | NativeAndroidProps);

export const NativePicker =
UIManager.getViewManagerConfig(ComponentName) != null
Expand Down
4 changes: 2 additions & 2 deletions src/Picker.tsx
Expand Up @@ -11,7 +11,7 @@ import { NativePicker } from './NativePicker';
import type { PickerGroupProps } from './PickerGroup';
import type {
NativeItem,
NativeOnChangeEvent,
NativeOnChange,
NativePickerDataItem,
PickerGroupChangeItem,
} from './types';
Expand Down Expand Up @@ -53,7 +53,7 @@ export const Picker = ({
textColor,
});

const handleOnChange: NativeOnChangeEvent = useCallback(
const handleOnChange: NativeOnChange = useCallback(
({ nativeEvent }) => {
if (onChange) {
onChange(nativeEvent);
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Expand Up @@ -5,3 +5,4 @@ export { PickerItem } from './PickerItem';
export type { PickerProps } from './Picker';
export type { PickerGroupProps } from './PickerGroup';
export type { PickerItemProps } from './PickerItem';
export type { PickerGroupChangeItem } from './types';
2 changes: 1 addition & 1 deletion src/types.ts
Expand Up @@ -23,6 +23,6 @@ export type NativePickerChangeEvent = {
value: string | number;
};

export type NativeOnChangeEvent = (
export type NativeOnChange = (
event: NativeSyntheticEvent<NativePickerChangeEvent>
) => void;

0 comments on commit 91e78bb

Please sign in to comment.