Cannot read property 'defaultText' of undefined when markdown is added
See original GitHub issueUsing storybook 5.1.1 and a few add-ons registered - @storybook/addon-info
storybook-addon-jsx
@storybook/addon-knobs
and a CRA typescript cut out.
This doesn’t works.
import React from "react";
import { withInfo } from "@storybook/addon-info";
import Label from "./label";
import { stories } from '../storybook';
import { text, boolean } from '@storybook/addon-knobs/react';
stories.add(
"Label",
() => (
<Label
text={text('text', 'Sample label')}
isActive={boolean('isActive', true)}
/>
),
{
info: {
text: `
description or documentation about my component, supports markdown
~~~js
<Label
text={text('text', 'Sample label')}
isActive={boolean('isActive', true)}
/>
~~~
`
}
}
);
But as soon as I remove the below code, it renders atleast
~~~js
<Label
text={text('text', 'Sample label')}
isActive={boolean('isActive', true)}
/>
~~~
Exact ERROR
TypeError: Cannot read property 'defaultText' of undefined
at http://localhost:9001/vendors~main.5f6f9e23f73905b9af8f.bundle.js:11483:24
at handleInterpolation (http://localhost:9001/vendors~main.5f6f9e23f73905b9af8f.bundle.js:1864:24)
at serializeStyles (http://localhost:9001/vendors~main.5f6f9e23f73905b9af8f.bundle.js:1949:15)
at http://localhost:9001/vendors~main.5f6f9e23f73905b9af8f.bundle.js:2396:100
at updateContextConsumer (http://localhost:9001/vendors~main.5f6f9e23f73905b9af8f.bundle.js:89332:19)
at beginWork (http://localhost:9001/vendors~main.5f6f9e23f73905b9af8f.bundle.js:89520:14)
at performUnitOfWork (http://localhost:9001/vendors~main.5f6f9e23f73905b9af8f.bundle.js:93160:12)
at workLoop (http://localhost:9001/vendors~main.5f6f9e23f73905b9af8f.bundle.js:93200:24)
at renderRoot (http://localhost:9001/vendors~main.5f6f9e23f73905b9af8f.bundle.js:93283:7)
at performWorkOnRoot (http://localhost:9001/vendors~main.5f6f9e23f73905b9af8f.bundle.js:94190:7)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:34 (8 by maintainers)
Top Results From Across the Web
Markdown Value rendered "Uncaught TypeError: Cannot read ...
I have some javascript code that gives this error when I added Simple Markdown Uncaught TypeError: Cannot read property 'value' of undefined ...
Read more >Markdown Mode for Emacs - Jason Blevins
A major mode for GNU Emacs for editing Markdown-formatted text files. ... URL ) by selectively adding or removing properties via the interactive...
Read more >InterSystems Partner Directory
Fix "Cannot read property 'toLowerCase' of undefined" error on startup (#693). Report problem if isfs workspace definition points to non-existent server ...
Read more >How to get content from the editor and set content | TinyMCE
After the TinyMCE editor is added to the initial example, ... Like the (annoying) “Cannot read property 'setContent' of null” error.
Read more >Error in render: "TypeError: Cannot read property 'length' of ...
... Error in render: "TypeError: Cannot read property 'length' of undefined ... form-white"> <h2 class="text-center default-text py-3">Quizzes</h2> <ul ...
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
The issue is only present when you try to add code blocks to the markdown. For basic documentation it works fine, but as soon as you insert a code block into the markdown it attempts to use the
syntaxhighlighter
.https://github.com/storybookjs/storybook/blob/7ee997698df4908ec716c5cfb6b59053469b04a9/lib/components/src/syntaxhighlighter/syntaxhighlighter.tsx#L32-L46
It breaks at line 36 specifically, at
color: theme.color.defaultText,
(but it would break anyways later on, this is just the first time you are tunneling into theme)This is because
theme
is coming through as{}
sotheme.color
is undefined and thus it breaks attheme.color.defaultText
. Not sure why the theme is an empty object in this case, I’m not too familiar with the code / emotion-js which I think the theming is using.Here’s what it should be:
https://github.com/storybookjs/storybook/blob/b19e5bc5c36d6d51257ae6f1eb43872634013813/lib/theming/src/base.ts#L36
Here’s where it is added to the theme:
https://github.com/storybookjs/storybook/blob/b19e5bc5c36d6d51257ae6f1eb43872634013813/lib/theming/src/global.ts#L104
I have this issue as well… With 50+ components, removing the JS markdown from each story isn’t very doable.