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.

Error in nextTick: "Error: Can't insert child, because the reference node has a different parent.

See original GitHub issue

Version

2.4.0

Reproduction link

https://play.nativescript.org/?template=play-vue&id=08ozhM&v=27

Platform and OS info

CLI: 6.1.2, Cross-platform modules: 6.1.2, Android Runtime: 6.1.2, iOS Runtime: 6.1.1, Plugin(s): nativescript-vue 2.4.0, nativescript-material-ripple 2.4.2

Steps to reproduce

RadListView implementation:

<RadListView id="songs-alphabet-order-list" ref="songsAlphabetOrderList" for="song in songsAlphabetOrder" @itemTap="onNavigationAlphabetItemTap">
  <v-template name="header">
    <StackLayout>
      <FlexboxLayout>
        <Label .../>
      </FlexboxLayout>
    </StackLayout>
  </v-template>
  <v-template>
    <list-item :song="song"/>
  </v-template>
  <v-template name="footer">
    <FlexboxLayout>
      <Label .../>
    </FlexboxLayout>
  </v-template>
</RadListView>

List item implementation:

<MDRipple>
  <GridLayout columns="auto,*">
      <Label .../>
  </GridLayout>
</MDRipple>

What is expected?

The RadListView should not throw the error.

What is actually happening?

On Android I have implemented RadLisView with header and footer template. The list has about 150 items. After some time scrolling down and up I get this:

JS: [Vue warn]: Error in nextTick: "Error: Can't insert child, because the reference node has a different parent."

and the RadLisView shows me repeating group of same items. I need to close and restart the app to get back the right items in list.

I have used more RadListView components in this app and the error is thrown on all of them if I scroll up and down on the component.

I have posted the same issue here: NativeScript/NativeScript/issues/8006 I don’t know if it is a {N} or {N}-vue related issue.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
rigor789commented, Oct 23, 2019

@phlegx If you set a key like that, it will force Vue to re-create the view tree under the list-item element, this will be noticeable in large lists, because scrolling will not be smooth, since whenever a view gets recycled, it will be also re-created - somewhat defeating the purpose of view-recycling.

Let’s keep the issue open, and figure out what causes the error instead!

1reaction
rigor789commented, Oct 29, 2019

@phlegx I have not seen the v-if in the original playground - I would have advised against it sooner!

v-if should not be used in a ListView, because it requires DOM/Node operations, such as adding/removing children. This defeats the purpose of view recycling, as there is no way to optimize these operations.

Either use v-show, which only visually hides the elements without expensive DOM/Node operations, or use separate templates for different types.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Can't insert child, because the reference node has a ...
Error in nextTick: "Error: Can't insert child, because the reference node has a different parent. #1281. Open.
Read more >
Uncaught NotFoundError: Failed to execute 'insertBefore' on ...
The reason is that node.insertBefore(newNode, existingNode) uses node as a reference to the element that surrounds the existingNode .
Read more >
failed to execute 'insertbefore' on 'node' - You.com - You.com
Error : Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child...
Read more >
5. Helper APIs - Node: Up and Running [Book] - O'Reilly
Finally, we log a message to the console. When Node runs the program, it evaluates all the code, which includes outputting 'End of...
Read more >
Process | Node.js v19.3.0 Documentation
The 'exit' event is emitted when the Node.js process is about to exit as a ... errors in an application while using the...
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