我无法使用反应代码片段运行这个repl.it。
你能告诉我我哪里出问题了吗?
发布于 2022-03-04 22:38:18
任何包含React模板的JavaScript文件都需要使用.jsx文件扩展名,然后需要导入React。
App.jsx
import React from 'react';
import { useState, useEffect, useRef } from "react";
//import ReactDOM from "react-dom";
function App() {
const [inputValue, setInputValue] = useState("");
const count = useRef(0);
useEffect(() => {
count.current = count.current + 1;
});
return (
<>
<input
type="text"
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
/>
<h1>Render Count: {count.current}</h1>
</>
);
}
export default App;https://stackoverflow.com/questions/71347091
复制相似问题