@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
15 lines • 557 B
JavaScript
import React from "react";
export const requireReactElement = (children) => {
const isReactElement = React.isValidElement(children);
if (!isReactElement) {
throw Error(`Expected a single React Element child, but got: ${React.Children.toArray(children)
.map((child) => typeof child === "object" &&
"type" in child &&
typeof child.type === "string"
? child.type
: typeof child)
.join(", ")}`);
}
return children;
};
//# sourceMappingURL=requireReactElement.js.map