material-ui-phone-number: Reference error when used in server side rendering app

When this library is used in SSR react app, window is not defined error comes up.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 9
  • Comments: 15 (2 by maintainers)

Most upvoted comments

FYI: A workaround that works for me is to use next/dynamic:

export const MuiPhoneNumber = dynamic(
  () => import("material-ui-phone-number"),
  {
    ssr: false
  }
);

@alexplumb Thoughts on the above solution? This PR should solve this issue.

Just FYI - I tried @braxex 's PR on a Gatsby site and it seems to have fixed the SSR problem for me. Thanks @braxex !