Skip to content

render error TypeError: Cannot read properties of undefined (reading 'setExtraStackFrame') #1902

@goSunadeod

Description

@goSunadeod

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

Labels

questionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions