ReactJ中的多个丰富的文本编辑器
我是ReactJ的新手。
我在网站上使用CKeditor文本编辑器。我想添加一个功能,用户可以在其中单击“添加”按钮以根据需要添加与文本编辑器一样多。在尝试此代码时,我遇到了一个错误 无法读取未定义的属性(读取“名称”)
const [inputList, setInputList] = useState([{data: ""}]);
const handleInputChange = (e, index) => {
const { name, value } = e.target;
const list = [...inputList];
list[index][name] = value;
setInputList(list);
};
return (
<div>
return(
{inputList.map((x, i) => {
<CKEditor
name="data"
type="text"
value={x.data}
onChange={e => handleInputChange(e, i)}
/>
}
)
</div>
)
I am new to reactjs.
I am using CKEditor Text Editor on my website. I want to add a function where users can click on add button to add as much as Text Editor as they want. While trying with this code I was getting an error
Cannot read properties of undefined (reading 'name')
const [inputList, setInputList] = useState([{data: ""}]);
const handleInputChange = (e, index) => {
const { name, value } = e.target;
const list = [...inputList];
list[index][name] = value;
setInputList(list);
};
return (
<div>
return(
{inputList.map((x, i) => {
<CKEditor
name="data"
type="text"
value={x.data}
onChange={e => handleInputChange(e, i)}
/>
}
)
</div>
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论