Skip to Main Content
Builder.io Ideas
Created by Ersin Akinci
Created on Jul 12, 2023

Add ref.ref for non-React SDKs

You can use ref.ref inside content JS when using the React SDK to reference the DOM element for the content item, but this feature isn't provided for the other SDKs. This is a very useful feature when you want to manipulate the DOM for just the content instance being rendered.

Assigning a class name to a block in the Visual Editor and using document.querySelector in content JS doesn't guarantee uniqueness since the same content can be rendered multiple times on the same page using symbols. You can get a particular block's unique DOM element by using its id from the content block, but this is cumbersome.

For cross-compatibility and functionality, it would be great if we could add ref.ref to other SDKs, especially the upcoming v2 SDKs in Mitosis.

  • Attach files