Upgrading to v3 and splitting desk structure causes crashes in Sanity Studio
6 replies
Last updated: Dec 19, 2022
R
Hey Sanity Team, I just upgraded a test studio to v3.. I am trying to split my desk structure up into parts, but I am not sure if I am doing this correctly (not using typescript).. This is a similar layout to the Hydrogen Studio starter. This MIGHT be a bug with the studio, but currently if you split your desk structure up into parts, then change something within one of those parts the studio crashes. Here is what I have:`sanity.config.js`:
Then my
And finally my
Again, I am not sure if I am doing this correctly as there is really no other example of this other than the Shopify Hydrogen Studio.. If I make a change in the
plugins: [ deskTool({ structure }), ]
structurewhich is just
index.jsin my /Desk folder:
import { home } from './home' // Doc types const hiddenDocTypes = (listItem) => { const id = listItem.getId() if (!id) { return false } return ![ 'homePage', 'media.tag' // Media plugin ].includes(id) } export const structure = (S) => S.list() .title('Content') .items([ home(S), // Filter out docs already defined above ...S.documentTypeListItems().filter(hiddenDocTypes) ])
home.jsstructure schema:
// Icons import { HouseLine } from 'phosphor-react' export const home = (S) => S.listItem() .title('Home') .icon(HouseLine) .child( S.editor() .title('Home Page') .schemaType('homePage') .documentId('homePage') )
home.jsmy studo will crash.
Dec 16, 2022, 6:49 AM
M
I think the problem is with your const home. Needs to return the listItem
export const home = (S) => { return S.listItem() .title('Home') .icon(HouseLine) .child( S.editor() .title('Home Page') .schemaType('homePage') .documentId('homePage') ) }
Dec 16, 2022, 2:29 PM
Hey
user S
! To clarify, does the code you posted work but breaks after adding anything more to your home function?Dec 16, 2022, 6:40 PM
R
Hey
user M
the studio only breaks when I manually refresh the page or sometimes it happens on its own... I'm still not entirely sure of the culprit or if I am just doing something wrong with how much desk structure is made. Here is a screenshot of what happens upon a manual page refresh or sometimes randomly (without a manual refresh):Dec 16, 2022, 6:43 PM
R
user C
I did try this beforehand, but my studio still crashes occasionally (no change from what happens initially).. Good suggestion thoughDec 16, 2022, 6:44 PM
R
user M
For some reason when I rewrote the home.jsas the following the studio did not crash (so this works):
export const home = (S) => S.listItem({ title: 'Home', id: 'homePage', icon: HouseLine, child: () => S.document() .title('Home Page') .schemaType('homePage') .documentId('homePage') })
Dec 16, 2022, 10:14 PM
R
Hey
user M
just an update to this.. I found that I could use the regular schema and studio did not break if I added basePath: '/studio'into my sanity config. Probably because I have my studio and web folders to split up my project
Dec 19, 2022, 8:05 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.