react-grid-layout / react-draggable

React draggable component
MIT License
9.02k stars 1.03k forks source link

in typescript the type notice error: is not assignable to type 'IntrinsicAttributes #661

Open seanock opened 2 years ago

seanock commented 2 years ago

TS2322: Type '{ children: Element[]; list: TagItem[]; setList: Dispatch<SetStateAction<TagItem[]>>; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<ReactSortable> & Pick<Readonly<ReactSortableProps>, never> & InexactPartial<...> & InexactPartial<...>'.   Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ReactSortable> & Pick<Readonly<ReactSortableProps>, never> & InexactPartial<...> & InexactPartial<...>'.

my code:

type TagItem = { id: number, name: string, parent_id: number }

  const [tags, setTags] = useState<TagItem[]>([])

  <ReactSortable list={tags} setList={setTags}>
   {
                tags.map(tag => <TagItem key={tag.id} tag={tag} />)
   }
 </ReactSortable>
umakantp commented 1 year ago

Same is the case for I'm getting.

No overload matches this call.
  Overload 1 of 2, '(props: Partial<DraggableProps> | Readonly<Partial<DraggableProps>>): Draggable', gave the following error.
    Type '{ children: Element; handle: string; bounds: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Draggable> & Pick<Readonly<Partial<DraggableProps>>, never> & InexactPartial<...> & InexactPartial<...>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Draggable> & Pick<Readonly<Partial<DraggableProps>>, never> & InexactPartial<...> & InexactPartial<...>'.
  Overload 2 of 2, '(props: Partial<DraggableProps>, context: any): Draggable', gave the following error.
    Type '{ children: Element; handle: string; bounds: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Draggable> & Pick<Readonly<Partial<DraggableProps>>, never> & InexactPartial<...> & InexactPartial<...>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Draggable> & Pick<Readonly<Partial<DraggableProps>>, never> & InexactPartial<...> & InexactPartial<...>'.

It seems the reason for the error is: children prop from react-18 has been removed and react-draggable is not handling it.

umakantp commented 1 year ago

Yes, if we update to the latest version, this problem solves. I think this issue can be closed.