-
Notifications
You must be signed in to change notification settings - Fork 734
WheelPicker - generic value #2959
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
Conversation
@M-i-k-e-l Ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, mostly recurring comments, I did not want to miss them if we make changes
src/components/WheelPicker/Item.tsx
Outdated
import {WheelPickerAlign} from './types'; | ||
|
||
const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity); | ||
const AnimatedText = Animated.createAnimatedComponent(Text); | ||
|
||
export interface ItemProps { | ||
export interface ItemProps<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is exported as well we should add a default value or users (including private) will get broken: <T = string | number>
TBH I'd really like it if the WheelPicker
could get the default from here, but I am not sure how... Maybe we should add a type for it, type DefaultWheelPickerItemType = string | number
but it feels clunky... WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to pass the type from the Item either, I'll take a look.
Regarding the DefaultWheelPickerItemType we can use the existing ItemValueTypes
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because we should not remove the ItemProps
yet; and also I feel like it should have default
in it
if (_.isString(initialValue) || _.isNumber(initialValue)) { | ||
return _.findIndex(items, {value: initialValue}); | ||
if (_.isObject(initialValue)) { | ||
LogService.warn('UILib WheelPicker will stop supporting initialValue prop type as an object (ItemProps). Please pass string or number only'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this is what this refers to: export type ItemValueTypes = /* ItemProps | */number | string;
If we're only starting this migration we should probably only remove the type in the next major when we remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still support it so functionality won't break but they will get TS error that should force them to migrate or add ignore. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't usually do that IMO, we don't cause TS errors if we can avoid it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not related to the ItemValueTypes as I don't use it anymore. You mean I should defined initialValue as T & WheelPickerItemProps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remane it WheelPickerItemValue and defined it in types so I can export it from WheelPicker. I also exported outside
export const SectionsWheelPickerDriver = (props: ComponentProps) => { | ||
const driver = useComponentDriver<SectionsWheelPickerProps>(props); | ||
const sections = driver.getProps().children as SectionsWheelPickerProps; | ||
export const SectionsWheelPickerDriver = <T extends string | number = number>(props: ComponentProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this type here as well
Don't think we need the default = number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still have the default
…nto infra/WheelPicker_generic # Conflicts: # src/components/WheelPicker/WheelPicker.driver.tsx # src/components/sectionsWheelPicker/SectionsWheelPicker.driver.tsx
…nto infra/WheelPicker_generic
…nto infra/WheelPicker_generic
…nto infra/WheelPicker_generic
Description
WheelPicker - generic value
Changelog
WheelPicker - generic value
Additional info
ticket 1844