afoysal's avatar

React usage in Facebook comment

I am learning react.js. I am trying to develop an application where there is a feature like Facebook comment system.I would like to know "is Facebook comment coming from Database using AJAX request or it is placing text just from input box using React.js.

Before

enter image description here

After

enter image description here

Facebook comment reply is so fast. On the other hand in my application I can't make is fast like Facebook.

0 likes
4 replies
bobbybouwmann's avatar

Well it's indeed placing the text first in the layout and in the background it's posting it to the server using ajax or some other method. The most important thing indeed that it's happening on the background ;)

1 like
RoboRobok's avatar

You can either insert the comment to the DOM immediately or wait for approval. You can also combine these two, removing it from DOM on error.

There are many possible solutions for cool comment system. I personally like to have comments inserted immediately, but refreshed when they reach the server. Server can in theory change the content, like replace URLs to links, censor some words etc.

You can also think whether you want to return new comment's HTML from the server or just data.

1 like

Please or to participate in this conversation.