我无法动态地创建一个React组件。使用下面的代码,我看到了一个空白页,没有错误。
1)尝试创建一个名为“PieChart”的元素
2)以下是我在控制台中看到的两个错误。
1. Warning: <PieChart /> is using incorrect casing. Use PascalCase for
React components, or lowercase for HTML elements.
2. Warning: The tag <PieChart/> is unrecognized in this browser. If you
meant to render a React component, start its name with an
uppercase letter.
3)我已经在使用帕斯卡命名法“PieChart”
import PieChart from "../component/PieChart";
class App extends Component {
render() {
const GraphWidget = React.createElement("PieChart");
return (
<div>
{GraphWidget}
</div>
)
}
}
export default App;
PieChart
周围使用引号,即const GraphWidget = React.createElement(PieChart);
。 - Hunter McMillen