[英]I am trying to implement product quantity increment and decrement using react useState hooks
const { price, available, name, menimum } = service;
const [updatedQuantity, setUpdatedQuantity] = useState(menimum)
I am trying to implement useState default value is dynamically.我正在尝试动态实现 useState 默认值。 Minimum works properly console.log when I am set useState minimum value is return NaN
当我设置 useState 最小值时,最小值可以正常工作 console.log 返回 NaN
const { price, available, name, menimum } = service;
const [updatedQuantity, setUpdatedQuantity] = useState(menimum)
const handleDecrease = () => {
setUpdatedQuantity(pre => pre - 1)
}
const handleIncrease = () => {
setUpdatedQuantity(pre => pre + 1)
}
Here is what your code does:这是您的代码的作用:
Check the initial values of "service" if it comes with "menimum" value NaN or not.检查“服务”的初始值是否带有“最低”值 NaN。 Would be good if you can put more code for better analysis.
如果您可以放置更多代码以进行更好的分析,那就太好了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.