反应中的条件渲染错误 [英] Conditional rendering error in react native
本文介绍了反应中的条件渲染错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当条件渲染组件在反应本机时,我有一个问题。
它显示我这个错误信息:
I have a problem when conditional rendering a component in react native. it shows me this error message:
JavascriptException:{stack:错误:无法执行'importScripts' 'WorkerGlobalScope'
JavascriptException: {"stack":"Error: failed to execute 'importScripts' on 'WorkerGlobalScope'
这里是我的代码原则的一个例子
And here's an example of my code principe
export default class App extends Component {
render() {
return(
{this.customRender()}
);
}
customRender() {
var x = true;
if(x) {
return (<View />);
}
else return (<Text>False</Text>);
}
}
推荐答案
我解决了问题。
首先我禁用了远程调试,之后,错误消息改变了,现在它显示了在render方法中有一个语法错误,正是在return中,所以我改变了这一点:
Guys i fixed the problem. First i disabled the Remote debugging, after that the error message changed and now it shows that i have a syntax error in the render method, precisely in the return, so i changed this:
return({this.customRender()});
是
return(this.customRender());
现在可以使用。
这篇关于反应中的条件渲染错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文