问题描述
TextInput 没有正确更新,我不知道为什么。据我所知,一切状态明智的都是正确的,我没有看到它的接线方式有任何错误。
我不知道我错过了什么。
app.js
const [receivingState,setReceivingState]=useState({
barcodes:[
{code:"",validState:VALID_STATES[0]},{code:"",]
})
const HandleChange=(property,value,number)=>{
setReceivingState(prev=>{
prev.barcodes[number][property]=value;
return prev;
})
}
<Route path="/receiving" render={props=>(<ReceivingWindow props={props} slice={receivingState} handleChange={HandleChange}/>)} />
接收窗口
const slice = props.slice;
const barcodes = slice.barcodes;
const HandleChange = props.handleChange;
//in the return
{barcodes.map((x,i)=><ReceivingBarcode code={x.code} key = {`barcode${i}`} number={i} validState={x.validState} handleChange={HandleChange}/>)}
接收条码
const code = props.code;
const updateText=(text)=>{
console.log(text,"text is!!!!");
handleChange("code",text,props.number);
console.log("text => ",text);
}
//in the return
<TextInput style={STYLE.input} onChangeText={(e)=>updateText(e)} value={code} name="barcodeinput"></TextInput>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)