通过console.log()
使用reactjs后useState()
挂机,不返回此状态下的电流值,我该如何处理呢?
这是案例的代码,尝试弄清楚控制台日志显示是什么。
import React, { useState } from "react";
import ReactDOM from "react-dom";
function Weather() {
const [weather, setWeather] = useState();
return (
<input
value={weather}
onChange={(e) => {
setWeather(e.target.value);
console.log(weather);
}}
/>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<Weather />, rootElement);