grid-js / gridjs

Advanced table plugin
https://gridjs.io
MIT License
4.39k stars 240 forks source link

Compatibility issue? #1402

Open ghost opened 10 months ago

ghost commented 10 months ago

Describe the bug A clear and concise description of what the bug is.

When using gridjs v6.0.6, gridjs-react v6.0.1, NextJS 14 I get the following error

[Grid.js] [ERROR]: The container element [object HTMLDivElement] is not empty. Make sure the container is empty and call render() again

Code

'use client'

import { Grid } from 'gridjs-react'
import useSWR from 'swr'

const fetcher = (url) => fetch(url).then((r) => r.json())

export default function WebsiteTable() {
 const { data, error } = useSWR('/api/websites/get', fetcher)
 if (error) return <div>Error: {error.message}</div>
 if (!data) return <div>Loading...</div>

 const websites = data.websites

 const columns = [
  { id: 'id', name: 'ID', type: 'text' },
  { id: 'domain', name: 'Domain', type: 'text' },
 ];

 const rows = websites.map((website) => ({
  id: website.id,
  domain: website.domain
 }));

 return (
  <Grid
   columns={columns}
   data={rows}
  />
 )
}
stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.