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

findByProps({ name: ... }) returns multiple instances #3339

Open
DeepUpRosenthal opened this issue Aug 22, 2024 · 1 comment
Open

findByProps({ name: ... }) returns multiple instances #3339

DeepUpRosenthal opened this issue Aug 22, 2024 · 1 comment

Comments

@DeepUpRosenthal
Copy link

My scene-graph (renderer.toGraph()):

‌[
  {
    "type":"Group",
    "name":"MEASUREMENT",
    "children":[
      {
        "type":"Line2",
        "name":"MEASUREMENT-LINE",
        "children":[
          
        ]
      },
      {
        "type":"Group",
        "name":"MEASUREMENT-TEXT",
        "children":[
          
        ]
      }
    ]
  },
  {
    "type":"Group",
    "name":"SCANS",
    "children":[
      {
        "type":"Group",
        "name":"SCAN-CENTERED:scan-id-1",
        "children":[
          {
            "type":"Mesh",
            "name":"SCAN:scan-id-1",
            "children":[
              
            ]
          }
        ]
      },
      {
        "type":"Group",
        "name":"SCAN-CENTERED:scan-id-2",
        "children":[
          {
            "type":"Mesh",
            "name":"SCAN:scan-id-2",
            "children":[
              
            ]
          }
        ]
      }
    ]
  }
]

Now executing scene.findByProps({ name: "MEASUREMENT-LINE" }) results in an error:

Error: RTTR: Expected 1 but found 2 instances with props: {"name":"MEASUREMENT-LINE"}

This seems to be a bug.

My packages:

"react": "18.3.1",
"react-dom": "18.3.1",
"three": "0.167.1",
"@react-three/drei": "^9.111.2",
"@react-three/fiber": "^8.17.5",
"@react-three/test-renderer": "8.2.1",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.4.8",
"@testing-library/react": "16.0.0",
"@testing-library/user-event": "14.5.2",
"jest": "27.5.1",

Node.js v20.15.0

Can you help me?

@DeepUpRosenthal
Copy link
Author

UPDATE:
I found the findAll-function under node_modules/@react-three/test-renderer/dist/react-three-test-renderer.cjs.dev.js which is responsible for iterating the tree. There in line 704 it uses root.allChildren.forEach. Switched it to root.children.forEach, which works.

Do you have any idea why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant