Closed sibelius closed 4 years ago
@sibelius ,
Which version of inputmask are you using?
4.0.9
check if this helps you:
async componentDidMount() {
if (this.props.mask) {
const element = document.getElementById(`${this.props.mask}--${this.props.placeholder}`);
const inputMaskLazy = await import('inputmask');
const inputMask = new inputMaskLazy.default(
{ regex: this.props.mask },
{
placeholder: '',
...defaultMaskOptions,
...this.props.maskOptions,
},
);
inputMask.mask(element);
}
}
async componentWillUnmount() {
if (this.props.mask) {
const inputMaskLazy = await import('inputmask');
this.inputRef && this.inputRef.current && inputMaskLazy.remove(this.inputRef.current);
}
}
useEffect(() => {
if (mask) {
const element = document.getElementById(`${mask}--${placeholder}`);
const inputMask = new inputMaskLazy.default(
{ regex: mask },
{ placeholder: '', ...defaultMaskOptions, ...maskOptions },
);
inputMask.mask(element);
}
return () => {
if (mask) {
inputRef && inputRef.current && inputMaskLazy.remove(inputRef.current);
}
};
}, [mask, maskOptions, placeholder]);
@sibelius ,
Have you tried version 5.x?
v5 fixed this problem
but we got another one
Cannot read property 'createShadowRoot' of undefined
any guess?
@sibelius ,
I pushed an update on this, can you have a try.
fixed, tks
Hey.
I'm getting same ReferenceError: navigator is not defined
error on v5.0.8 with SvelteKit by just importing the module:
[vite] Error when evaluating SSR module /src/routes/some_page/+page.svelte: failed to import "inputmask"
|- ReferenceError: navigator is not defined
at 9845 (C:\Users\user\source\repos\the_repo\node_modules\inputmask\dist\inputmask.js:306:146)
...
I just have import Inputmask from 'inputmask';
line in my +page.svelte
which causes the error by itself.
@Joonel try to bump your version to v5.0.9-beta.6, this version contain the fix.
Trying to use inputmask using razzle
after adding:
I've got this