The state value is not being updated inside the callback function. It always shows the initial value instead of the updated value. However, I need to access the updated state values. How can I achieve this?
here I used directline npm package
directLine.activity$
.filter((activity) => activity.type === 'message')
.subscribe((message) => {
setCurrentMessage(message)
// current message not having updated value
currentMessage === message &&
dispatchMiddleware({
payload: {
message_type: 'MESSAGE',
},
type: 'MWD_CONVERSATIONS_FROM_WEB_SOCKET',
})
})