Commit cf45ede7 authored by Ricco Førgaard's avatar Ricco Førgaard
Browse files

Adds a key to each element in the data.

This is to give each element in the rendered list an ID as suggested by
React.js.
parent a8f3c283
......@@ -38,8 +38,12 @@ var root = './www',
serveData = function (response) {
console.log("Serve data");
var result = data.map(function (item, index) {
item.key = index;
return item;
});
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(JSON.stringify(data));
response.end(JSON.stringify(result));
},
handlePOST = function (request, response) {
......
......@@ -4,7 +4,7 @@ var Comment = require('./comment.jsx'),
render: function () {
var commentNodes = this.props.data.map(function (comment) {
var markedUpCommentText = converter.makeHtml(comment.text.toString());
return <Comment author={comment.author}>{comment.text}</Comment>;
return <Comment author={comment.author} key={comment.key}>{comment.text}</Comment>;
});
return (
<ul className="commentList">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment