react-split-pane icon indicating copy to clipboard operation
react-split-pane copied to clipboard

type declaration - fix missing `children` prop

Open ellanan opened this issue 2 years ago • 7 comments

React 18's types are more strict and the missing children prop results in this typescript error being thrown when using the component

Type '{ children: Element[]; css: SerializedStyles; split: "vertical"; minSize: number; maxSize: number; onDragStarted: () => void; onDragFinished: (newSize: number) => void; size: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<SplitPane> & { css?: Interpolation<Theme>; } & Pick<...> & InexactPartial<...> & InexactPartial<...>'.
  Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<SplitPane> & { css?: Interpolation<Theme>; } & Pick<...> & InexactPartial<...> & InexactPartial<...>'.ts(2322)

(anyone else running into this can use patch-package to modify node_modules/react-split-pane/index.d.ts in the meantime)

ellanan avatar May 25 '22 03:05 ellanan

@ellanan FYI,

  • optional children refer PropsWithChildren
  • update peerDependencies

joriewong avatar May 26 '22 03:05 joriewong

Updated to make the children prop optional!

Since the library still works with react version 16 and 17, would it make sense to keep the peerDependencies at ^16.0.0-0?

ellanan avatar May 27 '22 01:05 ellanan

already works with react 18.x

joriewong avatar May 27 '22 06:05 joriewong

Fork: https://www.npmjs.com/package/@roothub/react-split-pane

giscafer avatar Jun 15 '22 06:06 giscafer

👍 i hope this PR can merge soon

kelvinkoko avatar Jun 25 '22 23:06 kelvinkoko

@kelvinkoko use react-reflex instead

giscafer avatar Jun 30 '22 04:06 giscafer

i hope this PR can merge soon~

hockor avatar Jul 27 '22 09:07 hockor

Finally

marefati110 avatar Aug 22 '22 18:08 marefati110

I'm still getting this error. Since this is merge then why it is showing this error image

decpk avatar Oct 23 '22 11:10 decpk

It looks like there hasn't been a release since this patch. Could one of the maintainers publish a new release? Thanks!

AndrewDorne avatar Dec 16 '22 20:12 AndrewDorne

Please publish this.

rahulbarwalfluxon avatar Jan 18 '23 07:01 rahulbarwalfluxon

still not release?

Seventysevendays avatar Mar 08 '23 07:03 Seventysevendays

I also ran into the issue of missing children types after upgrading to React 18. So, I took a temporary measure like the following and will wait until the PR's changes are published to NPM.

If you just want to bypass the type issue while using React 18, you can create the d.ts file below:

// my-project/types/split-pane.d.ts
declare module 'react-split-pane' {
  declare class SplitPane extends React.Component<
    SplitPaneProps & {
      children?: ReactNode;
    },
    SplitPaneState
  > {}

  export default SplitPane;
}

selenehyun avatar May 04 '23 10:05 selenehyun