Skip to content

Commit 6b4eebc

Browse files
adids1221ethanshar
andauthored
Fix component support check to handle nested component names (#3658)
* Fix component support check to handle nested component names * Refactor component support check to use utility function for improved clarity * bump uilib-docs version to 3.20 --------- Co-authored-by: Ethan Sharabi <[email protected]>
1 parent a1c9df1 commit 6b4eebc

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

docuilib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uilib-docs",
3-
"version": "3.19.0",
3+
"version": "3.20.0",
44
"main": "./src/index.ts",
55
"scripts": {
66
"docusaurus": "docusaurus",

docuilib/src/components/pageComponents/ContentItem.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, {ComponentProps, useCallback, useMemo, useState} from 'react';
2-
import _ from 'lodash';
32
import '../ComponentPage.module.scss';
43
import {LiveProvider, LivePreview} from 'react-live';
54
import styles from './ContentItem.module.scss';
65
import ReactLiveScope from '../../theme/ReactLiveScope';
76
import CodeBlock from '../CodeBlock';
87
import CodeIcon from '../../assets/icons/code';
8+
import {isComponentSupported} from '../../utils/componentUtils';
99

1010
type ComponentItemProps = {
1111
componentName: string;
@@ -116,9 +116,7 @@ export const ContentItem = ({item, componentName, showCodeButton, category}: Con
116116
name = `Incubator.${name}`;
117117
}
118118

119-
const isComponentExists = !!_.get(ReactLiveScope, name);
120-
121-
if (isComponentExists) {
119+
if (isComponentSupported(name)) {
122120
return (
123121
<ComponentItem
124122
componentName={name}

docuilib/src/utils/componentUtils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import get from 'lodash/get';
12
import ReactLiveScope from '../theme/ReactLiveScope';
23

3-
const supportedComponentNames = Object.keys(ReactLiveScope);
4-
54
export const isComponentSupported = componentName => {
6-
return supportedComponentNames.includes(componentName);
5+
return !!get(ReactLiveScope, componentName);
76
};

0 commit comments

Comments
 (0)