Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bmtamim's avatar

Livewire Js Code cleanup issue.

Hi, Hope you guys are doing well.

I was working with a chat application when I faced an issue with cleanup js on Livewire. I was navigating from one friend's inbox to another friend's with wire:navigate so code creates multiple instances for one inbox.

Example: Chat A is chatting with Chat B and Chat C. So, In the Chat A dashboard there have 2 inboxes B and C. When B messages everything okay and When C message and Chat A goes to check the C inbox Was good, But when B did send another message and A was back to B's inbox the message was duplicated. When do page reloads and start working fine.

Now, when they go to C inbox and Then again back to B inbox now one message repeats 3 times because there 3 instance created for echo listeners on the same inbox.

The problem is when I navigate to inbox livewire doesn't do cleanup and when I back it execute my js code again.

Sorry, Maybe I am a bad explainer. IF you have time and have questions please ask me.

Thanks

0 likes
0 replies

Please or to participate in this conversation.