Page crashes when switching Playground to html view
See original GitHub issueBug Report
I have a Styled Components ThemeProvider
wrapped around the whole page to provide theme context.
const ComponentWrapper = ({ children }) => {
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
};
When I click the html
tab on a Playground the whole page crashes as the theme context is missing.
I think this is a duplicate of #184, except we’re using Docz V0.10.3.
Environment
- OS: macOS 10.13.6
- Node/npm version: Node 8.11.1/npm 6.1.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:16 (6 by maintainers)
Top Results From Across the Web
context is missing when switching to html view · Issue #184 ...
When switching Playground to html mode theme becomes an empty object. The text was updated successfully, but these errors were encountered: ...
Read more >NSURL properly returning HTML from URL in Playground but ...
I am using NSURL to get the HTML of a website which works great in the Playground, but crashes the simulator when I...
Read more >Playgrounds crashes all the time, … | Apple Developer Forums
IPad Playgrounds has started to routinely crash on me. It started crashing while I was trying to work with protocol meta types, so...
Read more >Freezes or crashes when switching to a specific layout in Civil ...
Issue: When switching to a specific layout tab, Civil 3D freezes and eventually crashes. Also, the following may be observed:.
Read more >Crashes :: People Playground General Discussions
Switch to the OpenGL backend By default, the game runs on DirectX. You can force the game to use OpenGL if you are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pedronauck I’ve got the same issue on a bigger project but I’ve made a simple repro of the problem here: https://github.com/ChristienGuy/docz-theme-provider-example.
I have a custom wrapper under
docz/wrapper.js
which is referenced in thedoczrc.js
file. The doc comes fromsrc/Button/Button.mdx
which uses the component insrc/Button/Button.js
You can recreate the problem with the following steps:
yarn
yarn docz:dev
localhost:3000
You’ll see the error
Cannot read property 'primary' of undefined
. In this instanceprimary
belongs to thetheme
object prop given to<ThemeProvider>
I also have a quick deployed version here: https://docz-themeprovider-example.netlify.com/Button
Where you can try and click the HTML button and you’ll see the same error
I think the problem is when a styled-component uses a value from the
theme
in<ThemeProvider>
. I think the reason you might not be seeing it in your example is that your example doesn’t use the passed intheme
prop anywhere.I was investigating here and I think that this happens because we use
renderToStaticMarkup
to transform to html and I don’t know why with styled-components using theme this crash. Maybe is something related to render static, I’m trying to figure out how fix this!