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

SOLVED: Component fails on second key pressing in the last input field #120

Open
mvarakin opened this issue Feb 18, 2021 · 2 comments
Open

Comments

@mvarakin
Copy link

mvarakin commented Feb 18, 2021

Hi there,

[For solution please see below]

here is part of my code

...
const [code, setCode] = useState('');
const onChange = (code) => {
setCode(code)
}
...

  <ReactCodeInput
    key={1}
    type="number"
    fields={4}
    name="name"
    disabled={false}
    onChange={onChange}
    style={{ width: 212 }}
    inputStyle={{ width: 44, fontSize: '1.5em' }}
  />

It renders 4 fields as supposed to.

When I type four numbers everything goes well - onChange invokes, code changes.

But when I press any keyboard key in the last input field once more I always got the following error
(it happens also if you start to type from the last field and just press key twice)

Uncaught TypeError: Cannot assign to read only property 'display' of object '#<Object>'
at Function.assign (<anonymous>)
at t.value (ReactCodeInput.js:271)

Also this error occurs even on 1st key press if I change onChange to
const onChange = (code) => null

SOLUTION

this prop
style={{ width: 212 }}
caused the above error

I removed it and everything worked fine

Hopefully the author fix it

Best regards..

@mvarakin mvarakin changed the title onChange fails on key pressing fields+1 character Component fails on second key pressing in the last input field Feb 18, 2021
@mvarakin mvarakin changed the title Component fails on second key pressing in the last input field SOLVED: Component fails on second key pressing in the last input field Feb 18, 2021
@40818419
Copy link
Owner

@mvarakin please create pr if you think it should be in codebase

@marefati110
Copy link

same problem

its look like happening when use the style prop.

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

No branches or pull requests

3 participants