Answer the question
In order to leave comments, you need to log in
How to make a React component out of this function?
There are 2 functions, should these functions be made a React component? And in general, if there is an intelligent React developer here, I can give a link to an open-source project, I don’t need a big code review. Thanks
// processMessage function is called when the chat service sends a message.
// jQuery object with the response and insert message after converstaion.
function processMessage(username, data) {
$('<span class="message">' + '[' + getCurrentTime() + '] ' + '<strong>' + username + ':</strong> ' + data + '</span><br/>').insertAfter($('#conversation'));
}
// updateUserList function is called when server sends an updated user list.
function updateUserList(data) {
$('#users').empty();
$.each(data, function(key, value) {
$('#users').append('<div class="username"><i class="fa fa-user" aria-hidden="true"></i> ' + key + '</div>');
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question