Skip to content

HTMLElement is not defined #1830

Closed
Closed

Description

@vatto1337
import React, { Component } from 'react'
import Layout from '../components/core/layout';
import { EuiButton } from '@elastic/eui';

export default class MyComponent extends Component {
  render() {
    return (
      <div>
        <Layout>
          This is a test.
          <EuiButton>Primary</EuiButton>
        </Layout>
      </div>
    );
  }
}

I've attached the errror that is showing up on browser.
error

I'm developing an app using Next.js.. Any ways to fix it ?

Activity

  1. changed the title [-]HTMLEleme[/-] [+]HTMLElement is not defined[/+] on Apr 12, 2019
  2. thompsongl commented on Apr 15, 2019

    @thompsongl
    Contributor

    My sense is that this is happening during a server-side render. Is that correct?

    Next.js uses jsdom (I believe) with SSR, which doesn't have HTMLElement globally available via window.

    This is polyfill-able, but SSR is not something we've given a lot of thought to yet. Correct me if I'm wrong, @chandlerprall

  3. chandlerprall commented on Apr 15, 2019

    @chandlerprall
    Contributor

    This is polyfill-able

    EUI's startup requires the whole browser environment to be available, including window. If these are available, React switches into a DOM-active mode and will interact with the environment e.g. adding event listeners. This means that every server-side render will pollute the polyfilled environment and would need to be destroyed & re-created between renders.

  4. elvenking commented on Jun 22, 2019

    @elvenking

    Does anyone have fix for that ? I would like to use EUI with NextJS. Its heartbreaking since EUI is definitely one of the nicest design systems i came across. Can someone provide hints how to implement it ?

  5. thompsongl commented on Sep 10, 2019

    @thompsongl
    Contributor

    #2074 is a better catch-all issue and gets at the real problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions