Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Oct 23, 2023
1 parent 5d37383 commit a90d8c9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion imports/minilinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,15 @@ export function useMinilinksSubscription<L extends Link<number>>(ml, query: Quer
const listenerRef = useRef<any>();
const dRef = useRef<any>();
const [d, setD] = useState();
const qRef = useRef<any>(query);
qRef.current = query;
useEffect(() => {
if (listenerRef.current) ml.emitter.removeListener('added', listenerRef.current);
if (listenerRef.current) ml.emitter.removeListener('updated', listenerRef.current);
if (listenerRef.current) ml.emitter.removeListener('removed', listenerRef.current);
listenerRef.current = (oldL, newL) => {
const prev = d || dRef.current;
const data = ml.query(query);
const data = ml.query(qRef.current);
if (!_isEqual(prev, data)) {
setD(data);
}
Expand Down

0 comments on commit a90d8c9

Please sign in to comment.