Devextreme-reactive: Build error using EventTracker when running Gatsby Build

Created on 15 Sep 2020  路  5Comments  路  Source: DevExpress/devextreme-reactive

I'm using ...

  • [ ] React Grid
  • [X] React Chart
  • [ ] React Scheduler

Current Behaviour

Using the component EventTracking in the project, running Gatsby Build has a compilation error (see screenshot below):
"window" is not available during server side rendering

Expected Behaviour

Build should complete successfully.

Steps to Reproduce

  1. Create a new Gatsby project.
  2. Copy paste any example code from tooltip component:
    https://devexpress.github.io/devextreme-reactive/react/chart/docs/guides/tooltip/
  3. Run Gatsby Build command line.

Screenshots

image

Environment

  • devextreme-reactive: 2.7.1
  • gatsby: 2.21.1
  • react: 16.13.1
  • browser: Chrome 85.0.4183.102 (64bits)
  • bootstrap: none
  • react-bootstrap: none
  • material-ui/core: 4.9.12

Suggestion Solution

Replace faulty code by

    if (typeof window !== 'undefined' && window) {
      if ('ontouchstart' in window) {
        handlers.touchstart = moveHandler;
      } else {
        handlers.mousemove = moveHandler;
        handlers.mouseleave = leaveHandler;
      }
    }
Chart bug

All 5 comments

For information, I have tested my change using npm link and it did fix my build issue.

Hi @mstephano,

Thank you for your interest in our Grid and for your contribution! We have some rules on how to name pull requests and how to test components. I'll help you with this.

@LazyLahtak Great, sure no problem. Or you could always just include my suggestion on how to resolve (or you can have your own solution) to your fork. If you do that, then you can delete my pull request :)

Hi @mstephano,

We have released the 2.7.2 version of DevExtreme Reactive with this fix.

Thank you very much for the quick fix. I was a little late but have I tested the fix in 2.7.3 and I can confirm that it worked!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ProjectaJE picture ProjectaJE  路  3Comments

slava-lu picture slava-lu  路  3Comments

Vaccano picture Vaccano  路  3Comments

franklixuefei picture franklixuefei  路  3Comments

glenpadua picture glenpadua  路  3Comments