我是 reactjs 的新手,我试图获取 textarea 字符数,当用户输入 textarea 但无法获取计数时需要显示它也抛出状态对象是只读错误。我的代码是
import React from "react";
export default function FullWidthTabs() {
const [textAreaCount = 0, textAreaTotal = 250] = React.useState(0);
const recalculate = e => {
console.log("event value:", e);
textAreaCount = e.target.value.length;
};
return (
<textarea
type="text"
rows={5}
className="full_height_Width"
onChange={recalculate}
/>
);
}