admin管理员组文章数量:1422330
I have a problem when conditional rendering a ponent in react native. it shows me this error message:
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>);
}
}
I have a problem when conditional rendering a ponent in react native. it shows me this error message:
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>);
}
}
Share
Improve this question
asked Dec 11, 2016 at 16:18
AtefAtef
1,3221 gold badge14 silver badges27 bronze badges
2
- 2 Maybe this thread helps you? github./facebook/react-native/issues/6035 – Henrik R Commented Dec 11, 2016 at 17:18
- Can you take this error on debug environment? – Yasemin çidem Commented Dec 11, 2016 at 18:49
3 Answers
Reset to default 2Guys 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()});
to this
return(this.customRender());
and now it works.
One problem could have nothing to do with the code, but it is a result of your application using the bundled JS-File in development mode. You should use the packager for the development and the normal bundled files for production usage. You can open the web browser with the "--allow-file-access-from-files" flag to use the bundled version in the development setting.
Another possible problem could be the self-closing View
-Tag.
Check the packager log, it's likely that you have a syntax error somewhere in your code, probably something very simple like a missing ma. Run a linter on your code, it will help you find the error if the error message frmo the packager log isn't helpful.
本文标签: javascriptConditional rendering error in react nativeStack Overflow
版权声明:本文标题:javascript - Conditional rendering error in react native - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745363531a2655404.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论