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

React useRef hook code not generated #97

Open
shubhamsapra97 opened this issue Apr 24, 2023 · 0 comments
Open

React useRef hook code not generated #97

shubhamsapra97 opened this issue Apr 24, 2023 · 0 comments

Comments

@shubhamsapra97
Copy link

We are facing a issue where our component requires a ref to be passed to the component. We are passing ref to useView via the scope property.

scope={{
  ref: React.createRef(),
}}

const {compilerProps, editorProps, errorProps, knobProps} = useView({
  componentName,
  imports: { ... },
  onUpdate(params) { ... },
  props: propsProp as Record<string, TProp>,
  scope,
});

But auto generated editorProps.code code does not contain the useRef hook.

const ref = React.useRef(null);

I deep dived inside the useView code. Inside getCode -> getAstReactHooks, only React.useState template being used to auto generate useState hook. Do we need useRef template here as well based on if scope contains a ref?

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