Unlock seamless workflows and faster delivery with our latest releases- get the details

React Internal Error when trying to Visualise or Edit a Schema

12 replies
Last updated: Mar 11, 2022
Hey all, I'm facing a very weird react internal error when trying to visualise or edit a schema:
I couldn't find anything specific in the GH repo, so wanted to do a quick check if it's something on my end
Mar 11, 2022, 12:10 PM
aaaaah my crash-reason no.1 šŸ™‚*Solution 1*: conditional rendering with {variable && ā€¦. } when visualizing inputs in the studio OR (the more fancy way)
*Solution 2*: define Types and set as required for variables inside your redering components

Both are found here in
my code (non-fancy quick copy-paste share for a friend)
Mar 11, 2022, 3:22 PM
Thanks for the reply. But how am I supposed to find the possible falty component? The whole stack trace points to react/sanity internals

 in StructureError (created by DeskToolRoot)
    in DeskToolRoot (created by RenderTool)
    in ErrorBoundary (created by RenderTool)
    in RenderTool (created by SchemaErrorReporter)
    in RouteScope (created by SchemaErrorReporter)
    in div (created by styled.div)
    in styled.div (created by ForwardRef(Box))
    in ForwardRef(Box) (created by Styled(Component))
    in Styled(Component) (created by ForwardRef(Flex))
    in ForwardRef(Flex) (created by Styled(Component))
    in Styled(Component) (created by SchemaErrorReporter)
    in div (created by styled.div)
    in styled.div (created by ForwardRef(Box))
    in ForwardRef(Box) (created by Styled(Component))
    in Styled(Component) (created by ForwardRef(Flex))
    in ForwardRef(Flex) (created by Styled(Component))
    in Styled(Component) (created by SchemaErrorReporter)
    in div (created by styled.div)
    in styled.div (created by ForwardRef(Box))
    in ForwardRef(Box) (created by Styled(Component))
    in Styled(Component) (created by ForwardRef(Flex))
    in ForwardRef(Flex) (created by Styled(Component))
    in Styled(Component) (created by SchemaErrorReporter)
    in SchemaErrorReporter (created by DefaultLayout)
    in DefaultLayout (created by DefaultLayoutRoot)
    in RouterProvider (created by DefaultLayoutRoot)
    in LoginWrapper (created by NormalizedLoginWrapper)
    in NormalizedLoginWrapper (created by DefaultLayoutRoot)
    in DefaultLayoutRoot (created by AppProvider)
    in div (created by styled.div)
    in styled.div (created by ForwardRef(Box))
    in ForwardRef(Box) (created by Styled(Component))
    in Styled(Component) (created by ForwardRef(Card))
    in Fe (created by ThemeProvider)
    in ThemeProvider (created by ThemeColorProvider)
    in ThemeColorProvider (created by ForwardRef(Card))
    in ForwardRef(Card) (created by Styled(Component))
    in Styled(Component) (created by AppProvider)
    in SnackbarProvider (created by AppProvider)
    in ToastProvider (created by AppProvider)
    in LayerProvider (created by AppProvider)
    in PortalProvider (created by AppProvider)
    in UserColorManagerProvider (created by AppProvider)
    in AppProvider (created by SanityRoot)
    in Fe (created by ThemeProvider)
    in ThemeProvider (created by SanityRoot)
    in ZIndexProvider (created by SanityRoot)
    in SanityRoot
    in AppContainer
Mar 11, 2022, 3:26 PM
I always knew, bc my desk only crashed when I opened the culprit in a view (so the pane basically).
Mar 11, 2022, 4:00 PM
user V
there may be more information about the error in your console.
Mar 11, 2022, 5:28 PM
user M
user M
the stack trace is mostly related to react internals, but I've also opened an issue about it:

https://github.com/sanity-io/sanity/issues/3186
Mar 11, 2022, 9:55 PM
This is the full stack trace
Mar 11, 2022, 10:00 PM
Are you using a hook outside of a functional component anywhere?
Mar 11, 2022, 10:00 PM
I'll have to debug this, I'm not very familiar with this project TBH. I'm having a hard time figuring out what's sanity land and what isn't
Mar 11, 2022, 10:04 PM
Okay! I was able to make it work. I've disabled the custom parts in sanity config and got it back to rendering, now I can properly narrow it down! Lovely
Mar 11, 2022, 10:17 PM
Found the problem. the
document-actions resolver
had a hook to fetch the current user inside of it.
Mar 11, 2022, 10:24 PM
Wicked! Thanks for the support everyone!
Mar 11, 2022, 10:24 PM
Awesome! Glad you got it sorted out!
Mar 11, 2022, 10:28 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.

Was this answer helpful?