Skip to content
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

Correct node ordering on mount/unmount #16

Open
giulioz opened this issue Sep 3, 2020 · 1 comment
Open

Correct node ordering on mount/unmount #16

giulioz opened this issue Sep 3, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@giulioz
Copy link
Member

giulioz commented Sep 3, 2020

No description provided.

@giulioz giulioz added the bug Something isn't working label Sep 3, 2020
@giulioz
Copy link
Member Author

giulioz commented Sep 4, 2020

If something unmounts-mounts it will be placed to the end of the flex, ignoring ordering:
https://github.com/react-spring/react-three-flex/blob/master/src/Box.tsx#L186

  // Make child known to the parents yoga instance *before* it calculates layout
  useLayoutEffect(() => {
    if (!group.current) return () => {}

    parent.insertChild(node, parent.getChildCount())
    registerBox(group.current, node, flexProps, centerAnchor)

    // Remove child on unmount
    return () => {
      parent.removeChild(node)
      if (group.current) {
        unregisterBox(group.current, node)
      }
    }
  }, [node, parent, flexProps, centerAnchor])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant