1nwf / Produx-v2

Detected the use of variables before they are defined JS-0357
Anti-pattern
Major
8 months ago2 years old
'setSysMsg' was used before it was defined
 45        dispath(setOnlineUsers(msg.users));
 46        return;
 47      }
 48      setSysMsg(msg); 49    },
 50    onOpen: () => {
 51      const token = localStorage.getItem("token");
 39    onMessage: ({ data }) => {
 40      const msg = JSON.parse(data);
 41      if (msg.type === "chat") {
 42        setMsgs([...msgs, msg]); 43        return;
 44      } else if (msg.type === "usersList") {
 45        dispath(setOnlineUsers(msg.users));
 39    onMessage: ({ data }) => {
 40      const msg = JSON.parse(data);
 41      if (msg.type === "chat") {
 42        setMsgs([...msgs, msg]); 43        return;
 44      } else if (msg.type === "usersList") {
 45        dispath(setOnlineUsers(msg.users));
'postId' was used before it was defined
 39            observer.current = new IntersectionObserver(async (entries) => {
 40                if (entries[0].isIntersecting && hasMore) {
 41                    await getComments({
 42                        postId: parseInt(postId as string), 43                        lastId: lastId,
 44                    })
 45                }
'setSubmit' was used before it was defined
 46      formData.append(`image${i + 1}`, productImages[i]);
 47    }
 48    await createProduct(formData);
 49    setSubmit(false); 50    dispatch(setShowStep2(false));
 51    setTimeout(
 52      () =>