Skip to content

Commit 4fc29e2

Browse files
author
Alice Koreman
committed
small refactor
1 parent b0659b6 commit 4fc29e2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/code-view/internal.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
import { Children, createElement, Fragment, isValidElement, ReactElement, useRef } from "react";
3+
import { Children, createElement, Fragment, ReactElement, useRef } from "react";
44
import clsx from "clsx";
55

66
import { useCurrentMode } from "@cloudscape-design/component-toolkit/internal";
@@ -48,9 +48,11 @@ export function InternalCodeView({
4848

4949
const regionProps = ariaLabel || ariaLabelledby ? { role: "region" } : {};
5050

51-
// Create tokenized elements of the content.
51+
// Create tokenized React nodes of the content.
5252
const code = highlight ? highlight(content) : textHighlight(content);
53-
const codeElement: ReactElement = isValidElement(code) ? code : createElement(Fragment, null, code);
53+
// Create elements from the nodes.
54+
const codeElementWrapper: ReactElement = createElement(Fragment, null, code);
55+
const codeElement = Children.only(codeElementWrapper.props.children);
5456

5557
return (
5658
<div

0 commit comments

Comments
 (0)