react_comments-8.x-1.0-beta2/js/src/src/utils/findCommentByIdRecursive.js
js/src/src/utils/findCommentByIdRecursive.js
export default function findCommentByIdRecursive(id, commentTree) {
let result = null;
commentTree.forEach(function(el, i) {
if (el.id === id) {
result = el;
}
else if (el.replies) {
el = findCommentByIdRecursive(id, el.replies);
if (el) result = el;
}
});
return result;
};
