From 4d1fd7d13ce29656b92b70b87ade540f22b29978 Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Tue, 9 Jan 2024 09:01:07 -0800 Subject: [PATCH] Fix EuiTreeView JSX typescript error --- src/components/tree_view/tree_view.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/tree_view/tree_view.tsx b/src/components/tree_view/tree_view.tsx index 772e121984d..d866bd7eb11 100644 --- a/src/components/tree_view/tree_view.tsx +++ b/src/components/tree_view/tree_view.tsx @@ -31,7 +31,7 @@ function hasAriaLabel( function getTreeId( propId: string | undefined, - contextId: string, + contextId: string = '', idGenerator: Function ) { return propId ?? (contextId === '' ? idGenerator() : contextId); @@ -123,8 +123,12 @@ export class EuiTreeView extends Component { constructor( props: EuiTreeViewProps, - context: ContextType + // Without the optional ? typing, TS will throw errors on JSX component errors + // @see https://github.com/facebook/react/issues/13944#issuecomment-1183693239 + context?: ContextType ) { + // TODO: context in constructor has been deprecated. + // We should likely convert this to a function component super(props, context); this.isNested = !!this.context;