Skip to content

Commit 55da6b7

Browse files
authored
Fix react nesting warning (#660)
In development, the following error showed up on several pages, because of `TextTruncated`'s default display if `stringList` was empty and `placeHolder` was undefined: ``` <div> cannot appear as a descendant of <p> ``` This error annoyed me so I decided to create a PR to fix it.
1 parent 69a810d commit 55da6b7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/TextTruncated/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface Props {
6161
placeHolder?: React.ReactElement;
6262
}
6363

64-
export default function TextTruncated(props: Props): JSX.Element {
64+
export default function TextTruncated(props: Props): JSX.Element | null {
6565
const { stringList, listSeparator, maxLengthPx, moreSeparator, moreText, textStyle, showAllStyle, placeHolder } =
6666
props;
6767
const [showAllOpen, setShowAllOpen] = useState(false);
@@ -156,6 +156,6 @@ export default function TextTruncated(props: Props): JSX.Element {
156156
) : null}
157157
</Typography>
158158
) : (
159-
placeHolder || <div />
159+
placeHolder || null
160160
);
161161
}

0 commit comments

Comments
 (0)