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

[EuiTreeView] JSX Typescript error #7452

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/upcoming/7452.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed an `EuiTreeView` JSX Typescript error
8 changes: 6 additions & 2 deletions src/components/tree_view/tree_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function hasAriaLabel(

function getTreeId(
propId: string | undefined,
contextId: string,
contextId: string = '',
idGenerator: Function
) {
return propId ?? (contextId === '' ? idGenerator() : contextId);
Expand Down Expand Up @@ -123,8 +123,12 @@ export class EuiTreeView extends Component<EuiTreeViewProps, EuiTreeViewState> {

constructor(
props: EuiTreeViewProps,
context: ContextType<typeof EuiTreeViewContext>
// Without the optional ? typing, TS will throw errors on JSX component errors
// @see https://github.com/facebook/react/issues/13944#issuecomment-1183693239
context?: ContextType<typeof EuiTreeViewContext>
) {
// TODO: context in constructor has been deprecated.
// We should likely convert this to a function component
super(props, context);

this.isNested = !!this.context;
Expand Down
Loading