Skip to content

Commit

Permalink
[EuiTreeView] JSX Typescript error (#7452)
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen authored Jan 9, 2024
1 parent e67ef5d commit 87b7151
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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

0 comments on commit 87b7151

Please sign in to comment.