Skip to content

Enable for server-side rendering. #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zaruda opened this issue Dec 17, 2018 · 10 comments
Closed

Enable for server-side rendering. #50

zaruda opened this issue Dec 17, 2018 · 10 comments

Comments

@zaruda
Copy link

zaruda commented Dec 17, 2018

element-closest dependency makes your package incompatible with server side rendering

@xidedix xidedix mentioned this issue Dec 20, 2018
@xidedix
Copy link
Member

xidedix commented Dec 20, 2018

duplicate #37

@xidedix
Copy link
Member

xidedix commented Dec 21, 2018

hi @zaruda
please update @coreui/react to v2.1.2 and let us know if this works for you

@zaruda
Copy link
Author

zaruda commented Dec 22, 2018

Hi @xidedix
I’ve contacted to element-closest maintainer and he had updated polyfill to work with node environment.
Your updates are also cool :)

@raitucarp
Copy link

raitucarp commented Dec 31, 2018

hi @xidedix, getComputedStyle cause SSR not rendering. Some function on SidebarNav is incompatible with Next.js

@zaruda
Copy link
Author

zaruda commented Jan 3, 2019

@raitucarp +1

@mingderwang
Copy link

+1

@ilyazarudny
Copy link

@xidedix
https://github.com/coreui/coreui-react/blob/master/src/Shared/layout/layout.js#L3

this document body breaks server side rendering

@ryuken
Copy link

ryuken commented Apr 14, 2019

I extended SidebarNav like this to make it work in NextJS/SSR:

import React from "react"
import { NavItem, NavLink } from "reactstrap"

import {
    AppSidebarNav,
} from "@coreui/react"

class SidebarNav extends AppSidebarNav {

    navLink = (item, key, classes) => {

        const url = item.url ? item.url : ""
        const itemIcon = <i className={classes.icon} />
        const itemBadge = this.navBadge(item.badge)
        const attributes = item.attributes || {}

        return (
            <NavItem key={key} className={classes.item}>
                {attributes.disabled ?
                    <NavLink href={""} className={classes.link} {...attributes}>
                        {itemIcon}{item.name}{itemBadge}
                    </NavLink>
                :
                this.isExternal(url) ?
                    <NavLink href={url} className={classes.link} active {...attributes}>
                        {itemIcon}{item.name}{itemBadge}
                    </NavLink> :
                    <NavLink to={url} className={classes.link} onClick={this.hideMobile} {...attributes}>
                        {itemIcon}{item.name}{itemBadge}
                    </NavLink>
                }
            </NavItem>
        )
    }

}

export default SidebarNav

The last NavLink is incorrect (it should be something like "Link" from "next/link" i guess

It would be nice if @coreui would make a base SidebarNav and let you choose if you want to use their react-router-dom version or use something like this 😋

@VyacheslavKazadaev
Copy link

@xidedix
https://github.com/coreui/coreui-react/blob/master/src/Shared/layout/layout.js#L3

this document body breaks server side rendering

Hello everyone. Has anyone been able to fix this?

@woothu
Copy link

woothu commented Jun 24, 2020

The issue should be solved in v3

@woothu woothu closed this as completed Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants