SimeonGriggs / sanity-remix-template

Sanity Studio v3 embedded into a Remix Vite application configured for Vercel hosting with visual editing
https://sanity-remix-template.sanity.build
164 stars 35 forks source link

useLiveMode errors #71

Open dvnrsn opened 5 months ago

dvnrsn commented 5 months ago

This issue might belong elsewhere but I thought I'd ask.

I'm trying to invoke useLiveMode in a hydrogen (remix) project without success.

useLiveMode({client, studioUrl: 'http://localhost:3333'});

I believe this hook is critical for VisualEditing to work. But when I invoke useLiveMode I am consistently failing at this line

// @sanity/react-loader/src/defineUseLiveMode.ts
(client as SanityClient)?.config().stega.studioUrl

// config is not a function

I am fairly certain I have the correct sanity client and I am even trying to provide studioUrl so it short circuits the nullish coalescing operator but it is still breaking.

setStudioUrl(
  studioUrl ?? typeof client === 'object'
    ? (client as SanityClient)?.config().stega.studioUrl
    : undefined,

Is it necessary to have this hook? Is there a way I may be able to get it to work?