I have the following code, which basically adds empty objects to an array.
handleAddNewRow = () => { this.setState({ rowData: [ { MEMBER: "", ALIAS: "", STATUS: "" }, ...this.state.rowData ] }) }
Lets say, I am passing an integer value to the function handleAddNewRow and then it dynamically adds the number of empty objects to the array based on the integer value, How is it possible?
handleAddNewRow
You can look at my function:
handleAddNewRow = (number) => { this.setState({ rowData: [ ...this.state.rowData, ...(new Array(number).fill({ MEMBER: "", ALIAS: "", STATUS: "" })) ] }); }
2.1m questions
2.1m answers
60 comments
57.0k users