NativeScript: TypeError: Cannot read property 'navigate' of undefined
Hi,
Since today I had this error on Android and IOS :
01-16 15:30:46.448 6921 6921 E MessageQueue-JNI: at com.tns.Runtime.callJSMethodNative(Native Method)
01-16 15:30:46.448 6921 6921 E MessageQueue-JNI: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
01-16 15:30:46.448 6921 6921 E MessageQueue-JNI: at com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
01-16 15:30:46.448 6921 6921 E MessageQueue-JNI: at com.tns.Runtime.callJSMethod(Runtime.java:983)
01-16 15:30:46.448 6921 6921 E MessageQueue-JNI: at com.tns.Runtime.callJSMethod(Runtime.java:967)
01-16 15:30:46.448 6921 6921 E MessageQueue-JNI: at com.tns.Runtime.callJSMethod(Runtime.java:959)
System.err: com.tns.NativeScriptException:
System.err: Calling js method onTouch failed
System.err: TypeError: Cannot read property 'navigate' of undefined
My code is simply :
import * as frameModule from "tns-core-modules/ui/frame";
var activate = function(args) {
const navigationEntry = {
moduleName: "views/activate/activate",
animated: true,
transition: {
name: "slide",
duration: 380,
curve: "easeIn"
}
};
var topmost = frameModule.topmost();
topmost.navigate(navigationEntry);
};
exports.activate = activate;
The strangest thing is that navigation works for some pages and not for others.
I found that this error could be if the path is not correct, OR my paths are correct (I checked)
TNS -v : 5.0.1
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (17 by maintainers)
Hi @kefahB, With the latest NativeScript, it is recommended to use
runinstead ofstart. Keep in mind that when you are using the run method, you need to declare a root component with a Frame object. Check out our template here. I would suggest to try declaring the Frame as it is shown in the template and check if you will still have a problem.