liusong1111 / synapse-extension

MIT License
0 stars 0 forks source link

[question] Do we need to return cleaner for onMessage.addListener in useEffect? #32

Open liusong1111 opened 4 years ago

liusong1111 commented 4 years ago

https://github.com/rebase-network/synapse-extension/blob/bb8fc827adca2ab2281480dd068858d1882ccbf4/src/ui/pages/ImportMnemonic/index.tsx#L112

  React.useEffect(() => {
    chrome.runtime.onMessage.addListener((msg, sender, sendResp) => {
      if (msg === MESSAGE_TYPE.IS_NOT_VALIDATE_MNEMONIC) {
        setValidate(false);
      } else if (msg === MESSAGE_TYPE.VALIDATE_PASS) {
        setValidate(true);
        history.push('/address');
      }
    });
  }, []);