Skip to content

Commit

Permalink
Fix EuiTreeView JSX typescript error
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Jan 9, 2024
1 parent e67ef5d commit 4d1fd7d
Showing 1 changed file with 6 additions and 2 deletions.
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 4d1fd7d

Please sign in to comment.