0

The current state is zero and it shows zero on the input, I want to change the input value to any other number? I didn't include the full code just where is having an issue. Thanks

 const [value, setValue] = useState(0)
<input type="number" value={value} min="0" onChange={handleOnChangeSoda} required/>
2
  • 1
    You need to post the code for handleOnChangeSoda. Commented Jan 7, 2021 at 10:39
  • const handleOnChangeSoda = e => { setSoda(sodaPrice * [e.target.value]) setValue(value) } Commented Jan 7, 2021 at 10:40

2 Answers 2

2
handleOnChangeSoda = (event) => {
  setValue(event.target.value)
}

the value set will be a string so if you want it to be a number do a ParseFloat or ParseInt on event.target.value

Sign up to request clarification or add additional context in comments.

Comments

0

const [value, setValue] = useState(0) <input type="number" value={value} min="0" onChange={(val)=>setValue(val)} required/>

//i think this will work

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.