Skip to content
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

Update PickerItem.tsx to allow values of type number #74

Merged
merged 3 commits into from
Aug 19, 2024

Conversation

panzacoder
Copy link
Contributor

Allow values for the picker to be strings or numbers, so that I don't have to do custom transformation logic on the values.

This is particularly useful for a picker for numeric values like height, where I really want to store it as a number and not a string.

Allow values for the picker to be strings or numbers, so that I don't have to do custom transformation logic on the values.

This is particularly useful for a picker for numeric values like height, where I really want to store it as a number and not a string.
Copy link

vercel bot commented May 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-mobile-picker ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2024 7:21pm

@panzacoder panzacoder changed the title Update PickerItem.tsx Update PickerItem.tsx to allow values of type number May 29, 2024
…be better to allow the values to be generics if they aren't strings? Would be interested in thoughts
@@ -23,7 +23,7 @@ export default function ModalPicker() {

const { year, month } = newValue
const newDayArray = getDayArray(Number(year), Number(month))
const newDay = newDayArray.includes(newValue.day) ? newValue.day : newDayArray[newDayArray.length - 1]
const newDay = newDayArray.includes(newValue.day as string) ? newValue.day : newDayArray[newDayArray.length - 1]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to add this coercion to the test. This could possibly be avoided through type inference or generics, instead of just a union as I added: string | number.

Interested in your thoughts @adcentury

@adcentury
Copy link
Owner

LGTM.
Thanks @panzacoder

@adcentury adcentury merged commit 66b3018 into adcentury:main Aug 19, 2024
2 checks passed
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