Skip to content

Migrate Picker implementation to TS and use Function component #1870

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 16 commits into from
Mar 9, 2022

Conversation

ethanshar
Copy link
Collaborator

@ethanshar ethanshar commented Feb 27, 2022

Description

Refactor the Picker component

  • Migrate to TS the main component (under a new file) and the internal sub components/files
  • Migrate components to function component
  • Fix and organized typing. All types are in the types file
  • It seems like a lot of changes, but no functional changes were done
  • I renamed the PickerModal to PickerItemsList since it doesn't contain a modal anymore

If you prefer to review it together cause it's a little overwhelming let me know.

Changelog

Refactor Picker component and convert to TS

@ethanshar ethanshar requested a review from Inbal-Tish February 28, 2022 15:16
@ethanshar ethanshar marked this pull request as ready for review February 28, 2022 15:16
LogService.warn('Picker in MULTI mode must accept an array for value');
}

// TODO: this warning should be replaced by the opposite
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO is confusing, please leave only the relevant warning and rewrite the comment if still relevant

// TODO: deprecate getItemLabel prop
// TODO: Add initialValue prop
// TODO: consider deprecating renderCustomModal prop
// TODO: deprecate onShow cause it's already supported by passing it in pickerModalProps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why change _.isPlainObject usage?
  2. getItemValue and getItemLabel deprecation started, so we can remove comments.
  3. Why not start with the deprecation of onShow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. For TS, when using comparison like this (typeof value === 'object'), Typescript actually interpret the right type of the value prop. When using lodash unfortunately it doesn't.
  2. They didn't really started, I just added the @deprecated annotation long time ago. We need to address it accordingly.
  3. That's not the purpose of this PR, notice that most of the TODOs here are old.

The main purpose of this PR is migrate to TS and function component, which is big as it is, I didn't want to add more stuff.

@@ -138,7 +138,7 @@ export default {
return require('./components/panningViews/panResponderView').default;
},
get Picker() {
return require('./components/picker').default;
return require('./components/picker/new').default;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are you routing to the old picker?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not, it's routing to the new

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you're keeping the old files as a reference?

Copy link
Collaborator Author

@ethanshar ethanshar Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and in case we'll have a big issue we can quickly use the old file without reverting the whole PR
After some time I'll just remove it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I suggest opening tickets for both completing this migration (and deleting old files) and starting the props migrations needed.

@Inbal-Tish
Copy link
Collaborator

@ethanshar Looks good. I had only small comments. Also, please fix example screens, there are examples with old API that produce warnings.

@ethanshar
Copy link
Collaborator Author

@ethanshar Looks good. I had only small comments. Also, please fix example screens, there are examples with old API that produce warnings.

The example still have old usages so we'll know we didn't break anything while making changes, in the end of the screen there's an example with a migrated usage

@ethanshar ethanshar requested a review from Inbal-Tish March 9, 2022 10:51
@Inbal-Tish Inbal-Tish merged commit c47ff67 into master Mar 9, 2022
@ethanshar ethanshar deleted the infra/PickerRefactor branch June 13, 2022 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants