๐ - maskitoTransform returns undefined
rikusen0335 opened this issue ยท 4 comments
Which package(s) are the source of the bug?
@maskito/core
Playground Link
unfortunately nothing...
Description
I am not digging down this behavior still, so I provide a short description:
We have the code like this:
const Test = ({ defaultValue: _defaultValue, ...props }) => {
const maskitoOptions = useMemo(
() =>
maskitoNumberOptionsGenerator({
thousandSeparator,
}),
[thousandSeparator]
)
const ref = useMaskito({ options: maskitoOptions })
const defaultValue = useMemo(
() => maskitoTransform(_defaultValue?.toString() ?? '', maskitoOptions),
[_defaultValue, maskitoOptions]
)
return <CustomInput {...props} ref={ref} defaultValue={defaultValue}>
}
In the local development, providing 3000 (Number)
to maskitoTransform
will return 3,000 (String)
,
but in the staging, providing 3000 (Number)
will return undefined
.
Maskito version
2.0.2
Which browsers have you used?
- Chrome
- Firefox
- Safari
- Edge
Which operating systems have you used?
- macOS
- Windows
- Linux
- iOS
- Android
@rikusen0335 Hello!
Unfortunately, without reproduction it is almost impossible for me to help you ๐ข
maskitoTransform
utility is harnessed by strict TypeScript.
And its signature does not contain undefined
:
maskito/projects/core/src/lib/utils/transform.ts
Lines 12 to 15 in 5ac91a5
Please, double check that in the runtime of the staging you don't provide undefined
/null
to maskitoTransform
.
@nsbarsukov
Thank you for quick response!
Well yeah, there should be reproduction here but I have not investigate the issue, and I wanna place this just a note for someone met similar.
Please, double check that in the runtime of the staging you don't provide
undefined
/null
tomaskitoTransform
.
That is the weird point. Well, I am providing value with nullish coalescing operator (foo ?? ''
) which should provide a value
(sorry, previously written code is wrong! Fixed it)
@rikusen0335 Hello!
Unfortunately, I'm closing this issue because it does not have any reproduction.
If you reproduce it, feel free to open new issue!
Yeah sure
I just wanna make a note here