Skip to main content
Question

How do you search for a node within a page?


Are you using Figma.getNodeById() which search through the entire document, or using Figma.currentPage ?

I noticed that in big documents with lots of pages getNodeById is slow

This topic has been closed for replies.

3 replies

Gleb
  • Power Member
  • 4710 replies
  • May 26, 2024

I don’t often use getnodebyid to avoid searching the whole document. How are you using this function? Using currentpage is much better as long as you know the node you are searching for is indeed on the current page.


  • Author
  • 7 replies
  • May 26, 2024

So we are using getNodeById when we need some data from that node. i see that the return type (Base Node) is different from findOne (Scene node). does it matter?

Basically I’m using the node id to search it, so I can do the same wit findOne?


Gleb
  • Power Member
  • 4710 replies
  • May 26, 2024

I mean usually I conceptually change the plugin to avoid get by id and similar functions, e.g. ask the user to select the node manually if the plugin is ok with that or store necessary data in the client storage instead of on the node, or if I need to find multiple nodes I search for all of them at once instead of using find by id on each one separately. Just some ideas, you didn’t explain what you are using it for so I can’t suggest anything concrete.

No, it doesn’t matter.

Sure.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings