Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'AutoSizer' cannot be used as a JSX component. #74

Closed
IbrahimIjai opened this issue Sep 20, 2023 · 1 comment · Fixed by #77
Closed

'AutoSizer' cannot be used as a JSX component. #74

IbrahimIjai opened this issue Sep 20, 2023 · 1 comment · Fixed by #77

Comments

@IbrahimIjai
Copy link

How can I fix this error please??

"'AutoSizer' cannot be used as a JSX component.
Its instance type 'AutoSizer' is not a valid JSX element.
The types returned by 'render()' are incompatible between these types.
Type 'ReactElement<any, string | JSXElementConstructor>' is not assignable to type 'ReactNode'.
Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor>' but required in type 'ReactPortal'.ts(2786"

It seems to be a minor issue but I cant get my head around it

Here is my component

'use client'

import React, { CSSProperties, FC, ReactElement, useCallback } from 'react'
import AutoSizer from 'react-virtualized-auto-sizer'
import { FixedSizeList } from 'react-window'

type RowCallback = (row: { index: number; style: CSSProperties }) => ReactElement

export interface ListProps {
className?: string
rowHeight?: number
rowRenderer: FC
rowData: TData[]
}

export type ListComponent = (props: ListProps) => React.ReactElement | null

export function List({ className, rowHeight, rowData, rowRenderer: RowComponent }: ListProps) {
const Row = useCallback<RowCallback>(
({ index, style }) => {
return <RowComponent style={style} {...rowData[index]} />
},
[RowComponent, rowData]
)

return (

{({ height }: { height: number }) => (
<FixedSizeList
width="100%"
height={height}
itemCount={rowData.length}
itemSize={rowHeight || 48}
className={className}
style={{ overflow: 'overlay' }}
>
{Row}

)}

)
}

@bvaughn
Copy link
Owner

bvaughn commented Jan 16, 2024

Change published in react-virtualized-auto-sizer@1.0.21


❤️ → ☕ givebrian.coffee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants