I want to a get a React component's content with JSX as a string
const Component = () => <div>Hello</div>
console.log(Component.toString())
// desired result: "() => alert('hello')"
But I get some strange object instead
"() => /*#__PURE__*/Object(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_6__["jsxDEV"])("div", {
children: "Hello"
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 182,
columnNumber: 26
}, undefined)"
For example a basic function's content prints out normally
const func = () => alert('hello')
console.log(func.toString())
// result: "() => alert('hello')"
Any idea how to get a string representation of a React component?