NextJS Error when importing custom cells
See original GitHub issueI 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:
- Created a year ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
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”
Thanks for the heads up I will fix this up. Not a big next user so I really appreciate it.