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

SashContent children and Typescript #16

Open
LindaJuffermans opened this issue Mar 6, 2023 · 6 comments
Open

SashContent children and Typescript #16

LindaJuffermans opened this issue Mar 6, 2023 · 6 comments

Comments

@LindaJuffermans
Copy link

I'm trying to use this in a Next w/Typescript project:

<SashContent className={styles.sashWrapLineActive}>
  <span className={styles.sashWrapLine}></span>
</SashContent>

Typescript complains about the span element:

types.d.ts(60, 5): The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & ISashContentProps'

Do I need to add anything to allow the element or is this a bug in split-pane-react?
On the interface, I see children is defined as JSX.Element[]

@InTheNooB
Copy link

Same here

@InTheNooB
Copy link

In my case it was because i was using react-split-pan instead of split-pane-react...

@RCQE
Copy link

RCQE commented Jun 29, 2023

Maybe you need to add sashRender paras like this: https://codesandbox.io/s/split-pane-themes-xmsqtt
And u can use the default like this: #12 (comment)

@cwellsx
Copy link

cwellsx commented Jan 5, 2024

I guess it's a bug in the definition of the children property of ISashContentProps

Instead of declaring it as type JSX.Element[] it should also support other types e.g. a single element.

Using React with Typescript, children is normally defined as being of type ReactNode see e.g. https://blog.logrocket.com/react-children-prop-typescript/

@cwellsx
Copy link

cwellsx commented Jan 5, 2024

FYI I too get the error in the OP if I try to compile this code using TypeScript.

The code in question is in (and copied from) the themes demo e.g.:

That demo is a *.jsx file not a *.tsx file.

@cwellsx
Copy link

cwellsx commented Jan 6, 2024

I worked-around this problem by using the normal typescript instead of trying to use a theme, and instead adding some CSS to get something looking like the "line" style.

sashRender={(_, active) => <SashContent active={active} type="vscode"></SashContent>}

and

.split-sash-content.split-sash-content-vscode {
  background-color: rgb(200,200,200);
  width: 2px;
}
.split-sash-content.split-sash-content-vscode.split-sash-content-active {
  width: 100%;
}

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

No branches or pull requests

4 participants