在屏幕之间切换时是否启用数据调用。
我可以使用此代码致电一次
async componentDidMount() {
return fetch("https://www.xxxx.com/app/messages", options)
}
答案 0 :(得分:1)
我解决了
i = 0
output = []
sublist = []
while i < len(TextFile_List) - 1:
line = TextFile_List[i]
next_line = TextFile_List[i+1]
if line == 'Header':
i += 2
elif line == '*' and next_line == '*':
output.append(sublist)
sublist = []
i += 2
else:
sublist.append(line)
i += 1
答案 1 :(得分:0)
在将componentDidMount
作为问题代码移动到屏幕上渲染时开始。您可以使用fetch
作为问题来导入数据。
示例
componentDidMount() {
return fetch("https://www.xxxx.com/app/messages", options)
.then(response => response.json())
.then(responseJson => {
this.setState({
resdata: responseJson.data
});
})
.catch(error => {
console.error(error);
});
}
答案 2 :(得分:0)
这取决于您使用的导航库。如@Brien Crean所述,如果您的路由库为React Navigation,则可以选中here。
如果您使用的是React Native Navigation,则需要选中here。
我强烈建议使用一些路由库来处理应用程序内部的导航,否则拦截事件(例如显示/隐藏组件)将非常困难。