0
我做了一個使用create-react-app的示例應用程序,並且在做npm start
時,它向我展示了默認的反應js頁面。然後我編輯裏面的src app.js到沒有顯示在做npm開始反應-app
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
<h1>Hello, world!</h1>,
document.getElementById('root')
);
但是這顯示了做npm start
一個空白頁。我查了一下,index.html中有一個<div id="root">
。那麼爲什麼這會顯示一個空白頁?
我檢查了控制檯,它顯示了2個錯誤:
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in.
Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in.