Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 响应本机更新并进入阵列_Javascript_Reactjs_React Native - Fatal编程技术网

Javascript 响应本机更新并进入阵列

Javascript 响应本机更新并进入阵列,javascript,reactjs,react-native,Javascript,Reactjs,React Native,我正在为一个应用程序编写一个阅读圣经的小代码,但在标记文本选择中的文本时遇到了问题 我可以为变量播放,但它不会传递到平面列表 你能帮我吗 var highlightsUser = []; for(let i = 0; i < 126; i++){ highlightsUser.push({uid: i, start: 0, end: 0}) } <FlatList data={ chapterData.verses } rend

我正在为一个应用程序编写一个阅读圣经的小代码,但在标记文本选择中的文本时遇到了问题

我可以为变量播放,但它不会传递到平面列表

你能帮我吗

var highlightsUser = [];

for(let i = 0; i < 126; i++){
  highlightsUser.push({uid: i, start: 0, end: 0})
}

<FlatList
            data={ chapterData.verses }
            renderItem={({ item, index }) => (
              <View style={{
                flexDirection: 'row',
                paddingBottom: 15,
                width: '98%'
              }}>
                <Text style={{

                  fontSize: 16,
                  fontWeight: 'bold',
                  color: '#FFF',

                }}>{ item.number }</Text>

                <SelectableText
                  menuItems={["Marcar", "Favoritar"]}
                  highlights={[ highlightsUser[index] ]}
                  highlightColor='rgba(255,255,0,0.5)'
                  style={{ fontSize: 16, color: '#FFF' }}
                  onSelection={({ eventType, content, selectionStart, selectionEnd }) => {
                    if(eventType === "Marcar") {
                      console.log(content);
                      console.log(selectionStart);
                      console.log(selectionEnd);

                      const myIndex = highlightsUser.findIndex((el) => el.uid === index);
                      highlightsUser[myIndex] = { start: selectionStart, end: selectionEnd }
                      console.log(`start: ${highlightsUser[index].start}, end: ${highlightsUser[index].end}`);
                    }
                  }}
                  value={ item.text }
                />
                
              </View>
            )}
          />
var highlightsUser=[];
for(设i=0;i<126;i++){
highlightsUser.push({uid:i,开始:0,结束:0})
}
(
{item.number}
{
如果(eventType==“Marcar”){
控制台日志(内容);
console.log(selectionStart);
console.log(selectionEnd);
常量myIndex=highlightsUser.findIndex((el)=>el.uid==index);
highlightsUser[myIndex]={开始:选择开始,结束:选择结束}
log(`start:${highlightsUser[index].start},end:${highlightsUser[index].end}`);
}
}}
值={item.text}
/>
)}
/>

标记文本选择中的文本您所说的“文本来源”是什么意思?我的问题是在转换为平面列表时更新数组。在console.log(
start:${highlightsUser[index].start},end:${highlightsUser[index].end});在节点提示中完美打印。。完整代码:标记文本选择中的文本您所说的“文本来源”是什么意思?我的问题是在转换为平面列表时更新数组。在console.log中(
start:${highlightsUser[index].start},end:${highlightsUser[index].end}
);在节点提示中完美打印。。完整代码: