'Multiple rich text editor in reactjs
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>
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
