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.

NextJS Error when importing custom cells

See original GitHub issue

I am using this package with next JS and I am running into the same issue mentioned in #260 even with the tree-shaking fixes.

I am loading the component under a dynamic import, but this won’t solve the issue because its not a ssr problem, its a deeper nextjs issue. I’ll comment with an explanation of the root problem, but it isn’t necessary to read to be able to fix this.

Reproducible example

// page.tsx

import dynamic from "next/dynamic";
const NeedGrid = dynamic(
    () => {
        return import("../../components/reusable/NeedGrid");
    },
    { ssr: false }
);

export default function Needs() {
    return (
        <>
            <div className="flex-grow lg:p-10 w-full">
                <NeedGrid />
            </div>
        </>
    );
}
// NeedGrid.tsx
import React from "react";
import { useCustomCells } from "@glideapps/glide-data-grid";
import { DropdownCell } from "@glideapps/glide-data-grid-cells";

export default function Grid() {
    const customRendererArgs = useCustomCells([DropdownCell]);

    return <div>HI</div>;
}

Error details

error - ./node_modules/@toast-ui/editor/dist/toastui-editor.css Global CSS cannot be imported from within node_modules. Read more: https://nextjs.org/docs/messages/css-npm Location: node_modules/@glideapps/glide-data-grid-cells/dist/js/cells/article-cell-editor.js

Linked error page: https://nextjs.org/docs/messages/css-npm

Why This Error Occurred

One of your dependencies (node_modules) imports a CSS file.

Link to the line in question: https://github.com/glideapps/glide-data-grid/blob/91b2843ba5b248b7485293b8bc9f6fe53fb3a1fd/packages/cells/src/cells/article-cell-editor.tsx#L4

Fix suggestions

Export one (or more) .css files so that users can import them. This could be either just one global style sheet or single style sheets for each component that needs them.

For an example of a package that does this, see https://github.com/dvtng/react-loading-skeleton. The first few lines of the project’s readme show how users need to import the exported css.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jassmithcommented, Jun 8, 2022

Im going to take the breaking change and document it. I think the number of people using the article cell today numbers in “me, myself, and I”

1reaction
jassmithcommented, Jun 8, 2022

Thanks for the heads up I will fix this up. Not a big next user so I really appreciate it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

module-not-found - Next.js
A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies;...
Read more >
import '~.......` in nextJS project - Stack Overflow
I don't understand where ~ is defined in a nextJS import. it sure does not correspond to the user's home folder, like in...
Read more >
Custom main throwing error · Issue #21175 · vercel/next.js
I need to make some changes to the body of the pages which needs custom document with custom head and main. _document works...
Read more >
Handling data fetching in Next.js with useSWR - LogRocket Blog
That said, you can define custom types for your own arguments in the simplest way possible like so: import useSWR from 'swr' const...
Read more >
read-excel-file - npm
import readXlsxFile from 'read-excel-file' // File. const input ... If the cell value is invalid, it should throw an error with the error ......
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