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.

Hi, I have a problem with server side rendering with Next.js.

Error:

Unexpected token {
/home/landsman/projects/company/web/node_modules/swiper/dist/js/swiper.esm.js:13
import { $, addClass, removeClass, hasClass, toggleClass, attr, removeAttr, data, transform, transition as transition$1, on, off, trigger, transitionEnd as transitionEnd$1, outerWidth, outerHeight, offset, css, each, html, text, is, index, eq, append, prepend, next, nextAll, prev, prevAll, parent, parents, closest, find, children, remove, add, styles } from 'dom7/dist/dom7.modular';
       ^

SyntaxError: Unexpected token {
    at Module._compile (internal/modules/cjs/loader.js:721:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/landsman/projects/company/web/node_modules/react-id-swiper/lib/ReactIdSwiper.js:25:20)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/landsman/projects/company/web/node_modules/react-id-swiper/lib/index.js:6:39)

Code:

import React from "react";
import Swiper from 'react-id-swiper';
// Need to add Pagination, Navigation modules
import { Pagination, Navigation } from 'swiper/dist/js/swiper.esm'
import "../scss/drupal/embeds/carousel-core.scss";

export default class Carousel extends React.Component {
    constructor (props) {
        super(props);
    }

    componentDidMount(){

    }

    render () {
        const { children, hidePagination } = this.props;

        const params = {
            modules: [Pagination, Navigation],
            pagination: {
                el: '.swiper-pagination',
                type: 'bullets',
                clickable: true
            },
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev'
            },
            spaceBetween: 30
        };

        if (hidePagination) {
            delete params.pagination;
        }

        return(
            <>
                <Swiper >
                    {children}
                </Swiper>
            </>
        )
    }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
oyilmaztekincommented, Apr 8, 2020

I think I am missing something. The server-side rendering has been already accomplished on the official documentation website. https://react-id-swiper.ashernguyen.site/example/multiple-slides-per-view . It can be seen the next server drawing skeleton of the slider area and it is providing valid HTML for slide contents at the beginning. Disabling js and refreshing the page doesn’t affect the result. It is SSR then. I think it would be great to hear your experience with server-side DOM creation @kidjp85.

1reaction
nghiepdevcommented, Jun 30, 2019

Next.js have problems with the new version 2.3.1. With CRA, Next.js… I think you need to create example repo for each of them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next js app with SSR is not pre-rendering HTML, so web- ...
I figured this issue out. ... I was performing conditional rendering, depending on a loading state, which was causing SSR not to take...
Read more >
[examples] SSR on the Next.js official example not working
Hi @mnajdova, I got an issue reporting SSR no longer working with Next and React 18. I started investigating only to find out...
Read more >
Create a custom error component in Next.js (SSR & CSR)
First, create a fresh Next.js project by running npx create-next-app@latest custom-error-component · stop npm in your terminal and run npm run ...
Read more >
Using Web Components With Next (or Any SSR Framework)
But for this post, we'll look at how to manage Web Components from any SSR framework, like Next.js, today. We'll wind up doing...
Read more >
Advanced Features: Error Handling
This documentation explains how you can handle development, server-side, and client-side errors. Handling Errors in Development. When there is a runtime error ......
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