Comments (10)
In my case, adding numbers to the input field works well, but when I am trying to delete the numbers, the app gets crashed with error: "TypeError: Cannot read properties of undefined (reading 'setSelectionRange')"
Please let me know if anyone has found any workaround.
from material-ui-phone-number.
Is there any workaround for this issue?
from material-ui-phone-number.
Guys, any update on this? Still crashing with React Hook Form,
from material-ui-phone-number.
Same issue getting on my side and my app to crash when changing value
For Example:
<MuiPhoneNumber
fullWidth
variant="outlined"
label="Phone no"
id="phone"
defaultCountry={'in'}
error={Boolean(errors && errors.phone)}
inputRef={register({phone: true})}
onChange={onChangePhoneHandler}
/>
Uncaught TypeError: Cannot read property 'setSelectionRange' of undefined
at e. (index.js:1)
at callCallback (react-dom.development.js:12490)
at commitUpdateQueue (react-dom.development.js:12511)
at commitLifeCycles (react-dom.development.js:19858)
at commitLayoutEffects (react-dom.development.js:22803)
at HTMLUnknownElement.callCallback (react-dom.development.js:188)
at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
at invokeGuardedCallback (react-dom.development.js:292)
at commitRootImpl (react-dom.development.js:22541)
at unstable_runWithPriority (scheduler.development.js:653)
at runWithPriority$1 (react-dom.development.js:11039)
at commitRoot (react-dom.development.js:22381)
at finishSyncRender (react-dom.development.js:21807)
at performSyncWorkOnRoot (react-dom.development.js:21793)
at react-dom.development.js:11089
at unstable_runWithPriority (scheduler.development.js:653)
at runWithPriority$1 (react-dom.development.js:11039)
at flushSyncCallbackQueueImpl (react-dom.development.js:11084)
at flushSyncCallbackQueue (react-dom.development.js:11072)
at flushPendingDiscreteUpdates (react-dom.development.js:21847)
at flushDiscreteUpdates (react-dom.development.js:21827)
at finishEventHandler (react-dom.development.js:764)
at batchedEventUpdates (react-dom.development.js:798)
at dispatchEventForLegacyPluginEventSystem (react-dom.development.js:3568)
at attemptToDispatchEvent (react-dom.development.js:4267)
at dispatchEvent (react-dom.development.js:4189)
at unstable_runWithPriority (scheduler.development.js:653)
at runWithPriority$1 (react-dom.development.js:11039)
at discreteUpdates$1 (react-dom.development.js:21887)
at discreteUpdates (react-dom.development.js:806)
at dispatchDiscreteEvent (react-dom.development.js:4168)
from material-ui-phone-number.
If you're using React Hook Form, which it looks like you might be, you can use the <Controller />
component and set as={MuiPhoneNumber}
on it. Check it out here.
This issue still should probably get fixed, but this work around worked for me.
from material-ui-phone-number.
I get the same issue and as=
will be deprecated soon
Important: This prop is getting deprecated in the next major version, use render instead.
from material-ui-phone-number.
The same error(
<Controller
control={control}
name={name}
render={({
field: { onChange, onBlur, value, name, ref },
fieldState: { invalid, isTouched, isDirty, error },
formState,
}) => (
<FormattedHTMLMessage id={lexeme}>
{(placeholder) => (
<MuiPhoneNumber
label="Phone Number"
data-cy="user-phone"
defaultCountry={defaultCountry}
value={value}
onChange={onChange}
onBlur={onBlur}
inputRef={ref}
name={name}
placeholder={placeholder}
helperText={error?.message}
error={!!error}
/>
)}
</FormattedHTMLMessage>
)}
/>
from material-ui-phone-number.
Any update on this? Still running into an issue with it with material-ui-phone-number v3.0.0 and react-hook-form v7.41.5
from material-ui-phone-number.
@jhallinan What worked for me was setting the ref inside inputProps prop:
<Controller
name={name}
rules={inputRules}
render={({ field: { ref, ...rest }, fieldState: { error } }) => {
return (
<MuiPhoneNumber
{...rest}
fullWidth
variant="outlined"
data-testid={name}
required={required}
error={!!error}
label={t<string>('phone_number')}
helperText={error?.message || helperText}
inputProps={{
ref: ref,
'data-testid': name + '-input',
...inputProps,
}}
countryCodeEditable={true}
{...props}
/>
);
}}
/>
This block:
inputProps={{
ref: ref,
'data-testid': name + '-input',
...inputProps,
}}
from material-ui-phone-number.
The caused of this error is this line:
inputRef={} Please remove it if you want a peace
from material-ui-phone-number.
Related Issues (20)
- Missing countries like Antarctica (+672) and Christmas Island (+61) HOT 2
- Add localization support HOT 1
- Masks are missing
- Doesn't work with Firefox HOT 4
- Useless clone of a wonderful component HOT 1
- Dense margin not applied properly
- There is no way to hide the prefix
- Can't disable country selection if input is saved and disabled HOT 1
- Content security Policy "nonce" tag for style element
- Issue on long prefixes, freezes the value
- Doesn't work with Morocco HOT 2
- React 18 support HOT 3
- Country conflict USA & CA HOT 2
- Bundle Size
- Flag with broke style on Firefox HOT 3
- Bug in typescript regions HOT 2
- React 18.2.0 not supported HOT 1
- Static files for nation flags have been unavailable. 404 when requesting
- Changing the input changes the flag as well.
- Phone Number Code for Guam
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-ui-phone-number.