onesine / react-tailwindcss-datepicker

Modern date range picker component for React using Tailwind 3 and dayjs. Alternative to Litepie Datepicker.
https://react-tailwindcss-datepicker.vercel.app/
MIT License
552 stars 169 forks source link

undefined is not an object (evaluating 'r[0].toUpperCase') #271

Closed nachodeh closed 3 months ago

nachodeh commented 3 months ago

This is happening consistently on Safari (iOS or Mac OS) when using a basic DatePicker with the default config (null starting date value)

The error is thrown here: https://github.com/onesine/react-tailwindcss-datepicker/blob/b4234be75dfc9edd2f286ccbf76d67c347156ae5/src/helpers/index.ts#L19

Doesn't happen on other OSs

patrickrbc commented 3 months ago

Happens to me as well, if I downgrade (npm i react-tailwindcss-datepicker@1.6.6) it works.

onesine commented 3 months ago

Hi @nachodeh, @patrickrbc ,

Thank you for this return and thank you for using our package.

The only endroid in the code where we use a similar expression to your code is the ucFirst

export function ucFirst(value: string) {
    return `${(value[0] || "")?. toUpperCase()}${(value || "")?. slice(1, value.length)}`;
}

We have production applications too, but we don’t have this problem. I just made a small change. I hope this will solve your problem.

onesine commented 3 months ago

@nachodeh, @patrickrbc I have just released version 1.7.1. Please update and retest to see if you still have this problem.

nachodeh commented 3 months ago

Thanks for the prompt update. It's a very weird one. I think some other dependency in my code may be causing it.

For now I switched to a different date picker but will test with the updated version ASAP and get back to you

onesine commented 3 months ago

You're welcome. I will wait for your answer. Feel free to add feedback, if you have any other concerns.

nachodeh commented 3 months ago

@onesine Just checked with the latest version and the issue is resolved. Thanks!