const Button = ({ title, count, onClick }) => {
console.log(`Rendering ${title}`)
return (
<button onClick={onClick}>
{title} ({count})
</button>
)
}
const Header = () => {
console.log("Rendering Title")
return <h1>App Title</h1>
}
const Parent = () => {
const [add, setAdd] = React.useState(0)
const [edit, setEdit] = React.useState(0)
const [remove, setRemove] = React.useState(0)
const handleAdd = () => setAdd(add + 1)
const handleEdit = () => setEdit(edit + 1)
const handleRemove = React.useCallback(() => {
setRemove(remove + 1)
}, [remove])
return (
<React.Fragment>
<Header />
<Button title="Add" onClick={handleAdd} count={add} />
<Button title="Edit" onClick={handleEdit} count={edit} />
<Button title="Remove" onClick={handleRemove} count={remove} />
</React.Fragment>
)
}
function App() {
return (
<div className="App">
<Parent />
<button onClick={console.clear}>Clear log</button>
</div>
)
}
ReactDOM.render( <App /> , document.getElementById('root'))
然后我得到 文件“ C:\ Users \ Administrator \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site- packages \ tensorflow__init __。py“,第24行,在 从tensorflow.python import pywrap_tensorflow#pylint:disable = unused-import 文件“ C:\ Users \ Administrator \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site- packages \ tensorflow \ python__init __。py“,第49行,在 从tensorflow.python导入pywrap_tensorflow 文件“ C:\ Users \ Administrator \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site- packages \ tensorflow \ python \ pywrap_tensorflow.py”,第74行,在 提高ImportError(msg) ImportError:回溯(最近一次调用最近): 文件“ C:\ Users \ Administrator \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site- packages \ tensorflow \ python \ pywrap_tensorflow.py”,第58行,在 从tensorflow.python.pywrap_tensorflow_internal导入* 文件“ C:\ Users \ Administrator \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site- packages \ tensorflow \ python \ pywrap_tensorflow_internal.py”,第28行,在 _pywrap_tensorflow_internal = swig_import_helper() 文件“ C:\ Users \ Administrator \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site- packages \ tensorflow \ python \ pywrap_tensorflow_internal.py”,第24行,在swig_import_helper中 _mod = imp.load_module('_ pywrap_tensorflow_internal',fp,路径名,描述) 文件“ C:\ Users \ Administrator \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ imp.py”,第242行,在 load_module 返回load_dynamic(名称,文件名,文件) 文件“ C:\ Users \ Administrator \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ imp.py”,第342行,在 load_dynamic 返回_load(spec) ImportError:DLL加载失败:动态链接库(DLL)初始化例程失败。
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="root"></div>