在LWC中使用react js时出现以下错误。任何想法如何解决这个问题。
未捕获(承诺)TypeError:c.createElement不是函数
LWC
import {
LightningElement
} from 'lwc';
import {
loadScript
} from 'lightning/platformResourceLoader';
//add as static resource
import React from '@salesforce/resourceUrl/react';
import ReactDOM from '@salesforce/resourceUrl/reactdom';
export default class Reactjslwc extends LightningElement {
async connectedCallback() {
//load react & react-dom
Promise.all([
loadScript(this, React),
loadScript(this, ReactDOM),
]).then(() => {
ReactDOM.render(React.createElement('div', null, 'Hello React'), this.template.querySelector('div'));
});
}
disconnectedCallback() {
ReactDOM.unmountComponentAtNode(this);
}
}
HTML
<template>
<p>ReactJS</p>
</template>