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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745363532a4624469.html
评论列表(0条)