bs-breakpoints
bs-breakpoints copied to clipboard
window is undefined and result is NULL in combination with Next.JS
I've tried to use a package in Next.JS project with server-side rendering SSR.
On first reload window is not defined
error is thrown.
When a component is rendered, state value for a breakpoint is null
Hi @mestro67,
First of all thanks for using my plugin 👍
It seems it's a specificty of Next.js, but you'll find some workarounds here: https://github.com/zeit/next.js/wiki/FAQ
My libs need to access the window
object because it adds a polyfill for IE users if needed. I do that because I follow Bootstrap 4 browser support
did you find a solution @mestro67 ?
Hi! Getting same issue. I think, that the root cause is that library code is evaluated on the stage of defining import and not after calling init(). I did a workaround by importing library via dynamic import inside useEffect
by it looks ugly and it requires to do the same trick every time you use it inside a new file/component and work with lib as a Promise like thing. Can we lazy-evaluate stuff that needs window upon init
call?