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.

Import Spectacle in server-side

See original GitHub issue

I want to use next.js to render a presentation with spectacle, but I get an error because the hash history is used.

Hash history needs a DOM
Invariant Violation: Hash history needs a DOM
    at invariant (/home/romelperez/projects/prhone/romelperez.com/node_modules/invariant/invariant.js:42:15)
    at createHashHistory (/home/romelperez/projects/prhone/romelperez.com/node_modules/history/createHashHistory.js:69:27)
    at Object.<anonymous> (/home/romelperez/projects/prhone/romelperez.com/node_modules/spectacle/lib/utils/controller.js:50:47)
    at Module._compile (module.js:643:30)
    at Module._compile (/home/romelperez/projects/prhone/romelperez.com/node_modules/source-map-support/source-map-support.js:492:25)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)

I don’t mind not rendering it from the server, but I need it to work in the client.

Is there any workaround?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
tim-softcommented, Apr 10, 2018

SSR support would be excellent, conditional require in componentDidMount is obviously not great on performance

Edit: Why not assume you’re on the first slide on the server, then goto the correct slide in the DOM if the hash is different? In most cases, the initial render where SSR comes into play will be the beginning.

1reaction
iamstarkovcommented, Sep 19, 2018

@dharmeshkakadia you do not import anything from spectacle manually, you should utilise (like I use Deck from the callback argument) render prop’s callback’s arguments which reflects spectacle’s exports and they are:

const spectacleExports = [
  "Anim",
  "Appear",
  "BlockQuote",
  "Cite",
  "CodePane",
  "Code",
  "ComponentPlayground",
  "Deck",
  "Fill",
  "Fit",
  "Heading",
  "Image",
  "GoToAction",
  "Layout",
  "Link",
  "ListItem",
  "List",
  "Magic",
  "Markdown",
  "MarkdownSlides",
  "Notes",
  "Quote",
  "S",
  "Slide",
  "SlideSet",
  "TableBody",
  "TableHeader",
  "TableHeaderItem",
  "TableItem",
  "TableRow",
  "Table",
  "Text",
  "Typeface",
  "themes"
];

and I dont see createTheme in this list

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js - import server-side package in a file contains both ...
Show activity on this post. Just copy & paste the contents of your file into it & you'll see which code gets bundled...
Read more >
Importing photos and videos - Spectacles Support
Once your Spectacles are paired with your phone, they can wirelessly import your 3D photos and videos (also known as “Snaps”) into Snapchat....
Read more >
Customs Ruling HQ 963785 - Classification of eyeglass cases
The spectacle cases may be imported with spectacle frames made of gold tone metal and as presented these frames have “demonstration” lens inserts....
Read more >
Fork Repository and Import Application for the Server-side ...
Import the application into your PDI from your fork of the repository. IMPORTANT: If you have already forked and imported the repository, you...
Read more >
HS Codes of Heading 9003 - Cybex Exim
We are a B2B Research based Advisory firm helping Export Import companies to grow their ... HS Codes of Heading 9003 : FRAMES...
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