Skip to content
Advertisement

Why Gun.js duplicate messages in ReactJs

I’m implementing gun.js in react application.But messages are duplicated on each render, and on each update. Can someone help to figure out what’s wrong with my code.

this my code .

JavaScript

then in my component : get message on each new update

JavaScript

send message function

JavaScript

Advertisement

Answer

My simple fix for that was add useRef()

JavaScript
Advertisement