react native textinput min number max nuber

Solutions on MaxInterview for react native textinput min number max nuber by the best coders in the world

showing results for - "react native textinput min number max nuber"
Juan Sebastián
30 Nov 2017
1  const onCheckLimit = (value: string) => {
2    const parsedQty = Number.parseInt(value)
3    if (Number.isNaN(parsedQty)) {
4      setQuantity(0) //setter for state
5    } else if (parsedQty > 10) {
6      setQuantity(10)
7    } else {
8      setQuantity(parsedQty)
9    }
10  }
11/* React Wrapper */
12        <Input
13          value={quantity}
14          onChangeText={onCheckLimit}
15          otherProps
16        />
17/*React Wrapper*/
18
19If the value passed is higher than the limit,
20 it will set the value to the limit. Otherwise, simply set the value that the user entered