question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing the reference to nodes will report "ERROR TypeError: Cannot read property 'data' of null"

See original GitHub issue

Minimal reproduction of the bug/regression with instructions:

https://stackblitz.com/edit/angular-tree-component-demo?file=src%2Fapp%2Fapp.component.html

Click the “update tree nodes” button will see the error, But the tree nodes are updated success.

Expected behavior:

No Error report.

Versions of Angular Tree Component, Angular, Node, affected browser(s) and operating system(s):

@circlon/angular-tree-component   ^10.0.0

@angular-devkit/architect          0.1100.2
@angular-devkit/build-angular      0.1100.2
@angular-devkit/core               11.0.2
@angular-devkit/schematics         11.0.2
@angular/cdk                       11.0.1
@angular/flex-layout               10.0.0-beta.32
@angular/material                  11.0.1
@angular/material-moment-adapter   11.0.1
@schematics/angular                11.0.2
@schematics/update                 0.1100.2
ng-packagr                         11.0.3
rxjs                               6.5.5
typescript                         4.0.5

system:

MacOS v10.14.6

Other information:

The error threw in node.isRoot method;

I would be willing to submit a PR to fix this issue

I’m not sure. [ ] Yes (Assistance will be provided if you need help to submit a pull request) [ ] No

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
eviltubecommented, Jun 7, 2021

Still not sure that it’s OK, but instead of node.IsRoot you can write node.parent == null || node.parent.data.virtual Here is my workaround: <div *ngIf="(node.parent == null || node.parent.data.virtual)" class="inline p-w-xxs">...</div>

2reactions
Hongyu-Zhuocommented, Dec 22, 2020

The error is reported in:

// projects/angular-tree-component/src/lib/models/tree-node.model.ts 70:45
get isRoot(): boolean { return this.parent.data.virtual; }

Modify to:

get isRoot(): boolean { return this.parent?.data.virtual; }
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to deal with TypeError: cannot read properties of null
Firstly, while programming it is a good practice to properly declare and assign the variable to a value. The “TypeError: null is not...
Read more >
TypeError: Cannot read property 'data' of null - Stack Overflow
As the error explains your queryResult property is null. Add another conditional check to see if the queryResult field is not empty in...
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >
Uncaught TypeError: Cannot read property of undefined In
This error occurs in Chrome Browser when you read a property or call a method on an undefined object . There are a...
Read more >
cannot read properties of null (reading 'matches') npm - You.com
I read the log file: TypeError: Cannot read properties of null (reading 'matches') at Link.matches. And I read the specific address in node.js....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found