-
-
Notifications
You must be signed in to change notification settings - Fork 136
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
Question
this is my code
export const getCurrentTemplate = (templateString: string) => {
const customParse = (htmlString: string) => {
return parse(htmlString, {
replace: domNode => {
const convertToReactElement = (node: DOMNode) => {
if (node.type === 'text') {
return node.data;
}
const children = (node.children || []).map(convertToReactElement);
switch ((node as Element).name) {
case 'text': {
return <>{children}</>;
}
case 'ai': {
return <Ai node={node as Element}>{children}</Ai>;
}
default:
return children;
}
};
return convertToReactElement(domNode);
},
});
};
AI is a react component
const Ai: FC<IProps> = ({ children }) => {
const handleClick =() => {
console.log('test')
}
return (
<span onClick={handleClick}>
{children}
</span>
);
};
export default Ai;
const parsedContent = getCurrentTemplate('this is demo<text>demo<ai>ask ai</ai></text>');
Why does the above code fail to render and report an error:
TypeError: Cannot read properties of undefined (reading 'setExtraStackFrame')
Keywords
TypeError: Cannot read properties of undefined (reading 'setExtraStackFrame')
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested