Q:

What is the common way to handle successful REST POST operation in UI using React and Redux

I have a Thread component responsible to render messages of the specific thread and a component to submit a new message. Thread component's state is managed by Redux, which provides asynchronous actions like FETCH_MESSAGES and POST_MESSAGE. Below is the simplified pseudo-code.
class Thread {
  messages: [] // This is actually a prop connected to Redux
  render = () => {
    messages.map(messageComponent)
    <SubmitMessageComponent />
  }
}

What is the common way to handle successful POST operation of new Message in the UI, when server sends the object back with id? Is it safe to push that object to the array of earlier fetched messages or should I fetch all messages again to ensure consistency? First operation seems efficient but disjointed. I'm considered about handling concurrent REST API operations from different sources properly. Fetching everything all over again would always ensure the consistency of the state, but would be redundant performance wise (Imagine there are near infinite amount of messages)
Is there de facto way to deal with create operation in web application user interface?

A:

Typical way to handle this is to reduce the state via a "messages" reducer handling the POST_MESSAGE action as you stated in your question, i.e something like this :
export default function reducer(state = initialState, action = {}) {
    switch (action.type) {
        [...]
        case POST_MESSAGE:
            return {
                ...state,
                messages: {
                    ...state.messages,
                    [action.id]: { ...action.message }
                }
            }
        [...]
    }
}

You didn't explain how and when you're fetching new messages, but if you're using some websocket the messages are pushed from the server to your app.
Maybe an other solution could be to add some timestamp to the POST_MESSAGE action, so the server can respond with only the newly appended messages from that time but not sure if it's really RESTfull.

