微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法呈现正确的状态,react-native - TextInput输入是粘性的 - 不会更新,但会加载正确的数据

如何解决无法呈现正确的状态,react-native - TextInput输入是粘性的 - 不会更新,但会加载正确的数据

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 举报,一经查实,本站将立刻删除。