Skip to content

React useRef hook code not generated #97

@shubhamsapra97

Description

@shubhamsapra97

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions