luncheon / reinvented-color-wheel

A vanilla-js touch-friendly HSV color picker inspired by Farbtastic Color Picker.
https://luncheon.github.io/reinvented-color-wheel/
Do What The F*ck You Want To Public License
59 stars 4 forks source link

Color picker (0.3.0) not working in Gatsby (3.0.1) #10

Closed primozpadar closed 3 years ago

primozpadar commented 3 years ago

Color picker does not work with SSR React pages.

Color picker version: 0.3.0 Gatsby version: 3.0.1 React version: 17.0.1

Build error message:

 ERROR #95312 

"window" is not available during server side rendering.

See our docs page for more info on this error: https://gatsby.dev/debug-html

  1 | export var onDrag = 
  2 | // for IE, Edge, Firefox, Chrome
> 3 | 'PointerEvent' in window ?
    | ^
  4 |     function (element, onDragStart, onDragMove) {
  5 |         element.addEventListener('pointerdown', function (event) {
  6 |             if (event.button === 0 && onDragStart(event) !== false) {

Probably it should check for typeof window somewhere in code like this:


if (typeof window !== "undefined") {
  doSomething();
}
luncheon commented 3 years ago

@primozpadar Thank you for your report. It reproduced. I fixed to not use window without checking if it exists, and published v0.3.1. Could you please check if the problem has been fixed?

primozpadar commented 3 years ago

I think it works properly now! 😄 I tried to build project with gatsby build and also gatsby develop and it works as it should.

luncheon commented 3 years ago

Thanks! Closing.