question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Page crashes when switching Playground to html view

See original GitHub issue

Bug 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

docz-error

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
ChristienGuycommented, Sep 10, 2018

@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 the doczrc.js file. The doc comes from src/Button/Button.mdx which uses the component in src/Button/Button.js

You can recreate the problem with the following steps:

  1. Pull repo: https://github.com/ChristienGuy/docz-theme-provider-example.
  2. yarn
  3. yarn docz:dev
  4. Go to localhost:3000
  5. Go to “Button” doc
  6. Click HTML view on the playground.

You’ll see the error Cannot read property 'primary' of undefined. In this instance primary belongs to the theme 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 in theme prop anywhere.

2reactions
pedronauckcommented, Sep 28, 2018

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found