Skip to content

root-view removal while changing the direct child #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
barelyhuman opened this issue Oct 24, 2022 · 1 comment · Fixed by #14
Closed

root-view removal while changing the direct child #13

barelyhuman opened this issue Oct 24, 2022 · 1 comment · Fixed by #14

Comments

@barelyhuman
Copy link
Owner

Shows an error on the lines of root views cannot be un-registered when trying
to remove a node containing children or for anything where a UI library might
try to replace the child altogether

Issue exists in: 0.1.1-beta.10

@barelyhuman
Copy link
Owner Author

This isn't just on the root view but even if you try to add an existing node again after it's been removed.

The probable cause is that the instance itself is being deleted from react-native on removal and this brings up an issue where the DOM will have to maintain a re-creation task for every delete call.

The positioning of this call can cause issues so might need more thinking but this does block creation of even the most basic of applications

eg:

  const saView = document.createElement('SafeAreaView')
  const text = document.createElement('Text')
  const text2 = document.createElement('Text')
  const text3 = document.createElement('Text')

  text.textContent = 'First One'
  text2.textContent = 'Second one'
  text3.textContent = 'Third one'

  Object.assign(text.style, styles.text)
  Object.assign(text2.style, styles.text)
  Object.assign(text3.style, styles.text)

  saView.appendChild(text)
  document.appendChild(saView)

  setTimeout(() => {
    saView.insertBefore(text2, text)
    saView.removeChild(text)
    saView.insertBefore(text3, text2) // will work

    // saView.insertBefore(text, text2) // will bring up another view removal error but with an index mis-match
  }, 1000)

barelyhuman added a commit that referenced this issue Oct 28, 2022
* hack: add a recreate method

on each child node tree there's a new recreate method which get's fired
everytime something is removed, since
react native also removes it's existence from the native side causing re-
mounting errors

* simplify examples

* add rebuildTree on append instead of remove

* add a multipage example component

* simplify nested condition for removal

* change the increment count for allocation of tags

hack to avoid colliding tags with react native

* ci: disable build

* chore: proper demo
Repository owner moved this from In Progress to Done in project/preact-native Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

1 participant