I was checked everything, All sections are working good but when I triggered a dispatch ,their dependencies invoked two time!
Bellow is my reducer function :
recieveMessage(
state,
{ payload: { message, topic } }: PayloadAction<IWebSocket>,
) {
console.log('Recive Message from websocket ', message, topic)
state.recive = { message, topic }
},
and useEffect
const { socketReducer: { recive } } = useSelector(RootSelector);
useEffect(() => {
recive && console.log("Fetch from redux")
}, [recive])
Why it fired two time?