Reactjs React-Native-Fecth阻断相互作用
在android上,当我抓取某物时,它会阻止场景中的任何交互,直到抓取完成。我目前正在使用Reactjs React-Native-Fecth阻断相互作用,reactjs,react-native,Reactjs,React Native,在android上,当我抓取某物时,它会阻止场景中的任何交互,直到抓取完成。我目前正在使用InteractionManager 在使用InteractionManager之前,我尝试直接获取,但这会导致转换延迟 有问题吗 var ProductRender = React.createClass({ getInitialState: function() { return { product: null, modalVisible: false,
InteractionManager
在使用InteractionManager
之前,我尝试直接获取,但这会导致转换延迟
有问题吗
var ProductRender = React.createClass({
getInitialState: function() {
return {
product: null,
modalVisible: false,
description: null,
ready: false
};
},
componentDidMount: function() {
InteractionManager.runAfterInteractions(() => {
fetch(ENDPOINT)
.then((response) => response.json())
.then((responseJson) => {
this.setState({product : responseJson.product, related: responseJson.related});
})
.catch((error) => {
console.error(error);
});
},
});
},
render: function() {...
我建议实现redux,并稍微研究一下redux thunk和异步操作
如果您一心想在类中使用fetch,我建议为它创建一个单独的异步方法 你不能自己处理吗?