0
votes

Im getting the above warning in the file. I have the following code in my RowForm's render function:

const RowForm = React.createClass({
    render: function() {
            return (
                <tr key={'#'} className="addIpsetListRow">
                    <td className="col-lg-1"></td>
                    <td className="col-lg-3">
                        <input type="text"
          .................
................)
});

The above code simply creates a row of form and i have no idea what i should put as a key to make that warning go away.

1
You are using the same key for every row. That's why.Murat Karagöz
@MuratK. im not looping through a data structure. And i call RowForm component any time when user clicks on a button. How could i assign a unique id to that ?ssss
Worst case you can generate random numbers.Murat Karagöz

1 Answers

0
votes

If you have no data you have to use a random number or a timestamp unfortunately. For example

<tr key={+new Date()} className="addIpsetListRow">