vasansr / pro-mern-stack

Code Listing for the book Pro MERN Stack
http://www.apress.com/in/book/9781484226520
343 stars 159 forks source link

Writing to MongoDB #39

Open dionys93 opened 6 years ago

dionys93 commented 6 years ago

Error in sending data to server. In console I get the Warning: Each child in an array or iterator should have a unique "key" prop. I've changed id to _id in App.jsx, so I'm not sure why I'm getting that warning. On refresh, the data shows up, but not upon immediate submission. Is this bc of a mongodb update?

dionys93 commented 6 years ago

Is anyone else getting this issue after the end of Chapter 6?

react.js:20209 Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of IssueTable. See https://fb.me/react-warning-keys for more information. in IssueRow (created by IssueTable) in IssueTable (created by IssueList) in div (created by IssueList) in IssueList

I have key already set in IssueTable:

function IssueTable(props) {
    const issueRows = props.issues.map(issue => <IssueRow key={issue._id} issue={issue} />);
    console.log(issueRows);
    const borderStyle = {border: "1px solid silver", padding: 6};
    return (
        <table className="bordered-table">
            <thead>
                    <tr>
                        <th>Id</th>
                        <th>Title</th>
                        <th>Owner</th> 
                        <th>Created</th>
                        <th>Effort</th>
                        <th>Completion Date</th>
                        <th>Title</th>
                    </tr>
            </thead>
            <tbody>
                {issueRows}
            </tbody>
        </table>
    )
}
tigranmk commented 4 years ago

Is anyone else getting this issue after the end of Chapter 6?

react.js:20209 Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of IssueTable. See https://fb.me/react-warning-keys for more information. in IssueRow (created by IssueTable) in IssueTable (created by IssueList) in div (created by IssueList) in IssueList

I have key already set in IssueTable:

function IssueTable(props) {
    const issueRows = props.issues.map(issue => <IssueRow key={issue._id} issue={issue} />);
    console.log(issueRows);
    const borderStyle = {border: "1px solid silver", padding: 6};
    return (
        <table className="bordered-table">
            <thead>
                    <tr>
                        <th>Id</th>
                        <th>Title</th>
                        <th>Owner</th> 
                        <th>Created</th>
                        <th>Effort</th>
                        <th>Completion Date</th>
                        <th>Title</th>
                    </tr>
            </thead>
            <tbody>
                {issueRows}
            </tbody>
        </table>
    )
}

you probably didn't include _id in your query.