Code.split JavaScript error while loading markdown into notes
See original GitHub issueDescribe the bug I recently upgraded to Storybook 5.1.3 and the notes addon no longer renders markdown from an external file. When clicking on the notes tab I’m presented with a blank screen with JS errors on the console.
First JS error:
vendors~main.09cec2e9bb0f85474aec.bundle.js:110516 Uncaught TypeError: code.split is not a function
at vendors~main.09cec2e9bb0f85474aec.bundle.js:110516
at memoizerific (vendors~main.09cec2e9bb0f85474aec.bundle.js:89466)
at vendors~main.09cec2e9bb0f85474aec.bundle.js:91996
at vendors~main.09cec2e9bb0f85474aec.bundle.js:124206
at updateContextConsumer (vendors~main.09cec2e9bb0f85474aec.bundle.js:30892)
at beginWork (vendors~main.09cec2e9bb0f85474aec.bundle.js:31080)
at performUnitOfWork (vendors~main.09cec2e9bb0f85474aec.bundle.js:34720)
at workLoop (vendors~main.09cec2e9bb0f85474aec.bundle.js:34760)
at HTMLUnknownElement.callCallback (vendors~main.09cec2e9bb0f85474aec.bundle.js:15557)
at Object.invokeGuardedCallbackDev (vendors~main.09cec2e9bb0f85474aec.bundle.js:15607)
The above error occurred in the <Context.Consumer> component:
in ManagerConsumer (created by NotesPanel)
in NotesPanel (created by Preview)
in div (created by Context.Consumer)
in Styled(div) (created by Preview)
in Provider (created by Preview)
in Provider (created by Preview)
in Preview (created by Context.Consumer)
in ManagerConsumer
in Unknown (created by Layout)
in div (created by Context.Consumer)
in Styled(div) (created by Preview)
in Preview (created by Layout)
in div (created by Context.Consumer)
in Styled(div) (created by Main)
in div (created by Context.Consumer)
in Styled(div) (created by Main)
in Main (created by Layout)
in Layout (created by Context.Consumer)
in WithTheme(Layout)
in Unknown
in Unknown (created by ResizeDetector)
in ChildWrapper (created by ResizeDetector)
in ResizeDetector
in div (created by Context.Consumer)
in Styled(div)
in Unknown
in Unknown (created by Manager)
in ThemeProvider (created by Manager)
in Manager (created by Context.Consumer)
in Location (created by QueryLocation)
in QueryLocation (created by Root)
in LocationProvider (created by Root)
in HelmetProvider (created by Root)
in Root
React will try to recreate this component tree from scratch using the error boundary you provided, LocationProvider.
Next error:
vendors~main.09cec2e9bb0f85474aec.bundle.js:110516 Uncaught TypeError: code.split is not a function
at vendors~main.09cec2e9bb0f85474aec.bundle.js:110516
at memoizerific (vendors~main.09cec2e9bb0f85474aec.bundle.js:89466)
at vendors~main.09cec2e9bb0f85474aec.bundle.js:91996
at vendors~main.09cec2e9bb0f85474aec.bundle.js:124206
at updateContextConsumer (vendors~main.09cec2e9bb0f85474aec.bundle.js:30892)
at beginWork (vendors~main.09cec2e9bb0f85474aec.bundle.js:31080)
at performUnitOfWork (vendors~main.09cec2e9bb0f85474aec.bundle.js:34720)
at workLoop (vendors~main.09cec2e9bb0f85474aec.bundle.js:34760)
at renderRoot (vendors~main.09cec2e9bb0f85474aec.bundle.js:34843)
at performWorkOnRoot (vendors~main.09cec2e9bb0f85474aec.bundle.js:35750)
The above error occurred in the <LocationProvider> component:
in LocationProvider (created by Root)
in HelmetProvider (created by Root)
in Root
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
Last error
Uncaught TypeError: code.split is not a function
at vendors~main.09cec2e9bb0f85474aec.bundle.js:110516
at memoizerific (vendors~main.09cec2e9bb0f85474aec.bundle.js:89466)
at vendors~main.09cec2e9bb0f85474aec.bundle.js:91996
at vendors~main.09cec2e9bb0f85474aec.bundle.js:124206
at updateContextConsumer (vendors~main.09cec2e9bb0f85474aec.bundle.js:30892)
at beginWork (vendors~main.09cec2e9bb0f85474aec.bundle.js:31080)
at performUnitOfWork (vendors~main.09cec2e9bb0f85474aec.bundle.js:34720)
at workLoop (vendors~main.09cec2e9bb0f85474aec.bundle.js:34760)
at renderRoot (vendors~main.09cec2e9bb0f85474aec.bundle.js:34843)
at performWorkOnRoot (vendors~main.09cec2e9bb0f85474aec.bundle.js:35750)
To Reproduce Steps to reproduce the behavior:
- Upgrade from 5.0.6 to 5.1.3
- npm run storybook
- click on a story with notes
- click notes tab
- blank screen appears with errors in console
Expected behavior Rendered HTML from markdown file appears within the notes area.
System:
- OS: MacOS
- Device: Macbook Pro 2018
- Browser: chrome, safari
- Framework: angular
- Addons: Notes
- Version: 5.1.3
Additional context I have disabled the markdown file and it returned to normal via:
{ notes: { markdown: notesFile } }
//replaced with
{ notes: 'hello world!' }
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
What is causing the error `string.split is not a function`?
This is because document.location is a Location object. The default .toString() returns the location in string form, so the concatenation will trigger that....
Read more >How To Handle Async Data Loading, Lazy Loading, and Code ...
In the next step, you'll asynchronously load components to split code into smaller bundles that a user will load as needed.
Read more >Handbook Markdown Guide - GitLab
Splitting long lines (preferably up to 100 characters) can make it easier to provide feedback on small chunks of text. Do not leave...
Read more >VS Code tips — Add images and links in Markdown by ...
Quickly insert images or create file links in Markdown files in VS Code by dragging and dropping files from the explorer while holding...
Read more >Markdown | IntelliJ IDEA Documentation - JetBrains
The Markdown editor provides several basic formatting actions in the ... want to disable code injection and syntax errors in code blocks.
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
Experienced the same bug after upgrade to 5.1.8
I feel everyones pain on this issue. I also ran into the same problem. I am using Storybook with Vue. My vue project was created using Vue CLI 3.x. Whenever I attempted to import the markdown and associate the markdown to the Storybook notes it would fail.
However, I don’t think this issue is really a problem with Storybook. It is more an issue with making sure you have a markdown-loader setup to actually load the source markdown string into Storybook.
It would be nice for Storybook to maybe throw a more human readable error that indicates to maybe check if you have installed a markdown loader into your webpack setup.
Long story short … If you are using Vue and Storybook and ran into this issue and want to load a markdown here is what I did to fix the problem…
exportSource
.Install this loader and associated dev dependencies:
$ npm install markdown-to-vue-loader vue-loader webpack --save-dev
vue.config.js
and update with the new markdown loader you just installed in step 1stories/index.stories.js
do the following: (This is just a boilerplate example)NOTE You will see that in the notes section where we link the actual markdown , I have added
.source
which is provided by themarkdown-to-vue-loader
. This will send the raw source markdown text as a string to the Storybook formatter so that the markdown will display correctly 😃You can now re-serve your Storybook and you should be able to now view the Markdown inside the Notes section of your component.
Hope this helps anyone who stumbles upon this.