# Pass ref to a custom component from visual editor

**URL:** <https://forum.builder.io/t/pass-ref-to-a-custom-component-from-visual-editor/1701>\
**Category:** Technical Questions\
**Tags:** react, nextjs\
**Created:** [February 3, 2022, 8:10pm UTC](https://forum.builder.io/t/pass-ref-to-a-custom-component-from-visual-editor/1701 "2022-02-03T20:10:56Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![anon36379674](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@anon36379674](https://forum.builder.io/u/anon36379674)\
**Post date:** [February 4, 2022, 8:23pm UTC](https://forum.builder.io/t/pass-ref-to-a-custom-component-from-visual-editor/1701/4 "2022-02-04T20:23:04Z")

</div>

Hello @luigiveoworld,

What you might be looking for is using our `<StateProvider>` component so that you can access this reference on state within the Builder Block context.

```auto
function hitHOC({ children, hits }: { children?: JSX.Element; hits: any }) {
  return <StateProvider state={{ hits }}>{children}</StateProvider>;
}

// Pass all hits back to any item
export const AlgoliaHitsWrapper = connectHits(hitHOC);

```

More detail here: [Component with bindings from plugin - #2 by steve](https://forum.builder.io/t/component-with-bindings-from-plugin/56/2)

I have not tried this with a ref yet, but I might be able to create an example quick.

---

_[View the full topic](https://forum.builder.io/t/pass-ref-to-a-custom-component-from-visual-editor/1701)._
