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

No access to ref within jsCode in v2 SDKs #2311

Open
ersinakinci opened this issue Jun 2, 2023 · 0 comments
Open

No access to ref within jsCode in v2 SDKs #2311

ersinakinci opened this issue Jun 2, 2023 · 0 comments

Comments

@ersinakinci
Copy link

ersinakinci commented Jun 2, 2023

Describe the bug
The new v2 SDKs don't pass a variable representing the framework component content JS scope (i.e., ref in the old React SDK), nor a variable for accessing the component's DOM element (i.e., ref.ref in the old React SDK). See https://github.com/BuilderIO/builder/blob/08a5a8d7cfb9612651d2b71839968be2d5da2f7f/packages/sdks/src/functions/evaluate.ts#L49C9-L62. Attempting to access ref or ref.ref from within content JS while running a v2 SDK results in an error.

To Reproduce
Try rendering a content item that has content JS that uses ref or ref.ref with a v2 SDK.

Expected behavior
I should be able to access the rendering component for the content with ref or the component's DOM node with ref.ref.

Screenshots
N/A

Additional context
Is ref and ref.ref only available in the React SDK? It's never been officially documented, even though it's a common (if advanced) use case. There needs to be a standardized way to access the component container in order to do DOM manipulations that can't be handled within the Visual Editor.

I created an open source library that contains a helper for working with ref: https://github.com/buildquick/buildquick/tree/main/packages/builder-utils#waitforrefelement. I'm concerned that it won't work anymore with the v2 SDKs and that my clients' sites will stop functioning correctly once they eventually upgrade.

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

2 participants