question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

styled.div is not a function

See original GitHub issue

I’m trying to use glide-data-grid in a new Next.js project, but I’m running into the follow error:

TypeError: styled.div is not a function

Call Stack <unknown> node_modules/@glideapps/glide-data-grid/dist/js/data-grid-overlay-editor/private/bubbles-overlay-editor-style.js (2:52)

The file that it’s complaining about imports styled from styles.ts. This is what styles.ts compiles to in my node_modules:

import baseStyled from "styled-components";

const dataEditorBaseTheme = {
  accentColor: "#4F5DFF",
  accentFg: "#FFFFFF",
  accentLight: "rgba(62, 116, 253, 0.1)",
  textDark: "#313139",
  textMedium: "#737383",
  textLight: "#B2B2C0",
  textBubble: "#313139",
  bgIconHeader: "#737383",
  fgIconHeader: "#FFFFFF",
  textHeader: "#313139",
  textGroupHeader: "#313139BB",
  textHeaderSelected: "#FFFFFF",
  bgCell: "#FFFFFF",
  bgCellMedium: "#FAFAFB",
  bgHeader: "#F7F7F8",
  bgHeaderHasFocus: "#E9E9EB",
  bgHeaderHovered: "#EFEFF1",
  bgBubble: "#EDEDF3",
  bgBubbleSelected: "#FFFFFF",
  bgSearchResult: "#fff9e3",
  borderColor: "rgba(115, 116, 131, 0.16)",
  drilldownBorder: "rgba(0, 0, 0, 0)",
  linkColor: "#4F5DFF",
  cellHorizontalPadding: 8,
  cellVerticalPadding: 3,
  headerFontStyle: "600 13px",
  baseFontStyle: "13px",
  fontFamily: "Inter, Roboto, -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, noto, arial, sans-serif",
  editorFontSize: "13px"
};
export const styled = baseStyled;
export function getDataEditorTheme() {
  return dataEditorBaseTheme;
}

Maybe also relevant is that I get the following error when bringing up the app, but it gives me no stack trace or indication where it’s coming from. It also doesn’t happen when refreshing the page, whereas the styled.div error does happen every time.

error - unhandledRejection: ReferenceError: document is not defined

This is what my tsconfig.json looks like:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jassmithcommented, May 11, 2022

Its the last FAQ question now in the readme.

0reactions
chris-aeviatorcommented, Jun 13, 2022

for anyone stumbling upon this: this happened to me also when only importing anything (e.g. GridCellKind) outside of my dynamicly included component

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styled.div is not a function after rollup built of format "es" #3700
Debugging within the lib's built has shown that styled. div is indeed undefined since styled holds default and just then has div (...
Read more >
reactjs - type error extend is not a function in styled components
The CustomElement.extend function was removed in styled components version 4, so you must be using version 4 or above, where it no longer ......
Read more >
FAQs - styled-components
styled -components v5 does not introduce any breaking public API changes, and adds the following: Total rewrite of the core stylesheet engine, ...
Read more >
styled() - MUI System
Utility for creating styled components. ... function BasicUsage() { return <MyComponent>Styled div</MyComponent>; } ... With styled (not recommended):.
Read more >
Styled Components - Emotion
Any interpolations or arguments that are functions in styled are called with ... </Parent>. <Child>Red because I am not inside a Parent</Child>. </div>....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found