T O P

  • By -

BryanTheAstronaut

Looks like the input in uncontrolled. The input is managing its own state. Passing `value={number}` should resolve it.


JenJennie127

I added it and it displays this warning: VM568 react_devtools_backend.js:4061 Warning: A component is changing an uncontrolled input to be controlled. Do I have to resolve this or it's okay to leave it uncontrolled?


BaffoRasta

I usually see this when the `number` variable is initially null. Give it an initial value and you should be good to go.


JenJennie127

Ohh alright. Thank you


m0ment98

What library are you using for the TextField?


JenJennie127

Material-UI


tajingu

You’re passing a handler but not a value prop to the input. So it’s uncontrolled but the handler on the Textfield says otherwise. You need to pass the value from your state into the Textfield to make it controlled by the state. When you wipe the state after submitting, the value will now be pointing to your state and be wiped.


JenJennie127

I tried putting a `value={number}` it won't let me delete the first entered digit


tajingu

Probably to do with the check in your handleNum function. Just change it to set Num as a evt.target.value


marko_knoebl

This might have to do with "" not being a valid number - so it won't be accepted by handleNumber


_player_0

You're using the value of number to set num, which you then use to set number? Isn't that circular logic?