Answers for "react native textinput min number max nuber"

0

react native textinput min number max nuber

const onCheckLimit = (value: string) => {
    const parsedQty = Number.parseInt(value)
    if (Number.isNaN(parsedQty)) {
      setQuantity(0) //setter for state
    } else if (parsedQty > 10) {
      setQuantity(10)
    } else {
      setQuantity(parsedQty)
    }
  }
/* React Wrapper */
        <Input
          value={quantity}
          onChangeText={onCheckLimit}
          otherProps
        />
/*React Wrapper*/

If the value passed is higher than the limit,
 it will set the value to the limit. Otherwise, simply set the value that the user entered
Posted by: Guest on July-01-2021

Code answers related to "react native textinput min number max nuber"

Code answers related to "Javascript"

Browse Popular Code Answers by Language