doczjs / docz

✍ It has never been so easy to document your things!
https://docz.site
MIT License
23.6k stars 1.46k forks source link

Playground component is failing due to undefined theme #1590

Open dbertella opened 3 years ago

dbertella commented 3 years ago

Bug Report

Describe the bug

I'm trying to use Playground component but is failing when adding a ThemeProvider from theme-ui in a custom wrapper

To Reproduce

I follow instruction in this comment https://github.com/doczjs/docz/issues/1474#issuecomment-671536726 and it seems to work fine. When adding Playground component I have an error

TypeError: Cannot read property 'plain' of undefined

It seems like Playground component is rerendering multiple time and at first theme is defined but after it become undefined https://github.com/doczjs/docz/blob/master/core/gatsby-theme-docz/src/components/Playground/index.js#L52

This is console.log(theme) at line 59 in the above file image

Uncaught TypeError: Cannot read property 'plain' of undefined
    at Module.editor (styles.js:5)
    at Playground (index.js:94)
    at renderWithHooks (react-dom.development.js:14986)
    at updateFunctionComponent (react-dom.development.js:17357)
    at beginWork (react-dom.development.js:19064)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3946)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3995)
    at invokeGuardedCallback (react-dom.development.js:4057)
    at beginWork$1 (react-dom.development.js:23965)
    at performUnitOfWork (react-dom.development.js:22780)
    at workLoopSync (react-dom.development.js:22708)
    at renderRootSync (react-dom.development.js:22671)
    at performSyncWorkOnRoot (react-dom.development.js:22294)
    at react-dom.development.js:11328
    at unstable_runWithPriority (scheduler.development.js:646)
    at runWithPriority$1 (react-dom.development.js:11277)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11323)
    at flushSyncCallbackQueue (react-dom.development.js:11310)
    at unbatchedUpdates (react-dom.development.js:22439)
    at legacyRenderSubtreeIntoContainer (react-dom.development.js:26021)
    at render (react-dom.development.js:26104)
    at app.js:133

Environment

dbertella commented 3 years ago

If it can help I created a dummy repository to reproduce the issue https://github.com/dbertella/test-docz it's fresh create react app with docz and theme ui installed

RyanPWalker commented 3 years ago

@dbertella Did you ever figure this out? I'm running into the same thing. Seems like the maintainers of docz have given up on it.

dbertella commented 3 years ago

Nope I gave up on docz for now. It's not working anymore since I updated few dependencies and i didn't look into it anymore