Skip to content

Start deprecation of Picker useNativePicker prop #2330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/src/screens/componentScreens/PickerScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ export default class PickerScreen extends Component {
<Picker
title="Wheel Picker"
placeholder="Pick a Language"
// useNativePicker
useWheelPicker
useNativePicker
// useWheelPicker
value={this.state.nativePickerValue}
onChange={nativePickerValue => this.setState({nativePickerValue})}
rightIconSource={dropdown}
Expand Down
8 changes: 6 additions & 2 deletions src/components/picker/helpers/usePickerMigrationWarnings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import _ from 'lodash';
import {LogService} from '../../../services';
import {PickerProps, PickerModes} from '../types';

type UsePickerMigrationWarnings = Pick<PickerProps, 'value' | 'mode'>;
type UsePickerMigrationWarnings = Pick<PickerProps, 'value' | 'mode' | 'useNativePicker'>;

const usePickerMigrationWarnings = (props: UsePickerMigrationWarnings) => {
const {value, mode} = props;
const {value, mode, useNativePicker} = props;
useEffect(() => {
if (mode === PickerModes.SINGLE && Array.isArray(value)) {
LogService.warn('Picker in SINGLE mode cannot accept an array for value');
Expand All @@ -18,6 +18,10 @@ const usePickerMigrationWarnings = (props: UsePickerMigrationWarnings) => {
if (_.isPlainObject(value)) {
LogService.warn('UILib Picker will stop supporting passing object as value in the next major version. Please use either string or a number as value');
}

if (useNativePicker) {
LogService.warn(`UILib Picker will stop supporting the 'useNativePicker' prop soon, please pass instead the 'useWheelPicker' prop and handle relevant TextField migration if required to`);
}
}, []);
};

Expand Down
1 change: 1 addition & 0 deletions src/components/picker/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export type PickerBaseProps = Omit<TextFieldProps, 'value' | 'onChange'> &
*/
renderCustomSearch?: (props: PickerItemsListProps) => React.ReactElement;
/**
* @deprecated pass useWheelPicker prop instead
* Allow to use the native picker solution (different style for iOS and Android)
*/
useNativePicker?: boolean;
Expand Down