tomkp / react-split-pane

React split-pane component
https://tomkp.github.io/react-split-pane
MIT License
3.2k stars 408 forks source link

Typescript warning with React 18 types #826

Open michaeltford opened 2 years ago

michaeltford commented 2 years ago

Describe the bug

When using with @types/react": "^18.0.15 a typescript warning is produced.

This is easily resolved by adding to the Props definition.

children: React.ReactNode; // 👈️ added type for children

Timmmm commented 2 years ago

It would help if you included the actual warning. I assuming its the same thing I'm getting:

Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<SplitPane> & Pick<Readonly<Props>, never> & InexactPartial<...> & InexactPartial<...>'.

Although that is an error, not a warning (not sure Typescript even has warnings).

johnflux commented 2 years ago

Is there any workaround for this?

michaeltford commented 2 years ago

@Timmmm . Yes, that's the message and you are correct that it's an error. I fixed this by forking and adding

children: React.ReactNode;

to SplitPaneProps in index.d.ts.

@johnflux I don't know of any workarounds but you could ignore using the react syntax below. (Note - it's 2 lines and will then ignore ALL typescript errors for SplitPane)

    {/* this lib is incompatible with react18. To fix     // children: React.ReactNode; needs to be added to SplitPaneProps.
     // @ts-ignore TS2322 */}
    <SplitPane>
Timmmm commented 2 years ago

Yeah I also just used {/* @ts-ignore */}.

yhusynin commented 2 years ago

Faced with the same issue, here is an example that I've found https://codesandbox.io/s/wr0gf

dturcotte commented 1 year ago

Here's the react 18 doc reference, children has to be added explicitly to props: https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-typescript-definitions

HristoP96 commented 9 months ago

So nobody is going to fix this small issue ?

vimalsharma124 commented 3 months ago

facing similar issue

vimalsharma124 commented 3 months ago

Found solution

https://www.npmjs.com/package/resizable-panes-react