NativeScript / NativeScript/NativeScript

TypeError: Cannot read property 'navigate' of undefined

Open
#9,762 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug-pending-triage
Dominant language
TypeScript
Stars
25.7k
Forks
1.7k
Avg merge
1d 5h
Merged PRs (30d)
35

Description

Issue Description
<Page loaded="pageLoaded" navigatingTo="onNavigatingTo">
    <StackLayout orientation="vertical">
        <Image src="~/images/apple.jpg" />
        <TextField hint="email address" keyboardType="email" autocorrect="false" autocapitalizationType="none" />
        <TextField hint="password" secure="true" />
        <Button class="bnt" text="sign in" tap="login" />
        <Button text="sign up for goes" tap="navigateToMainPage" />
    </StackLayout>
</Page>
export function navigateToMainPage() {
  Frame.topmost().navigate({
    moduleName: "views/register/register",
    animated: false
  });
}
Reproduction
tns run android --watch
Relevant log output (if applicable)
System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onClick failed
System.err: TypeError: Cannot read property 'navigate' of undefined
System.err:
System.err: StackTrace:
System.err: navigateToMainPage(file: app\webpack:\HelloWorld\app\views\login\login.js:8:15)
System.err:     at _handleEvent(file: app\webpack:\HelloWorld\node_modules\@nativescript\core\data\observable\index.js:233:0)
System.err:     at notify(file: app\webpack:\HelloWorld\node_modules\@nativescript\core\data\observable\index.js:216:0)
System.err:     at _emit(file: app\webpack:\HelloWorld\node_modules\@nativescript\core\data\observable\index.js:256:0)
System.err:     at ClickListenerImpl.onClick(file: app\webpack:\HelloWorld\node_modules\@nativescript\core\ui\button\index.android.js:28:0)
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1175)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1153)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1149)
System.err:     at com.tns.gen.java.lang.Object_vendor_16521_28_ClickListenerImpl.onClick(Object_vendor_16521_28_ClickListenerImpl.java:18)
System.err:     at android.view.View.performClick(View.java:7125)
System.err:     at android.view.View.performClickInternal(View.java:7102)
System.err:     at android.view.View.access$3500(View.java:801)
System.err:     at android.view.View$PerformClick.run(View.java:27336)
System.err:     at android.os.Handler.handleCallback(Handler.java:883)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:100)
System.err:     at android.os.Looper.loop(Looper.java:214)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:7356)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Environment

No response

Please accept these terms

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with app/views/login/login.js, where navigateToMainPage calls Frame.topmost().navigate. Run tns run android --watch and reproduce the sign-up button failure, then trace the relevant NativeScript navigation entry point. Done means the button navigates to the register module without throwing the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.