perawallet / connect

JavaScript SDK for integrating Pera Wallet to web applications.
https://perawallet.app
Other
64 stars 20 forks source link

ESLint warning in next.js codesandbox example #87

Open aorumbayev opened 1 year ago

aorumbayev commented 1 year ago

Hello Pera team, just wanted to report a small eslint warning regarding one of the next.js examples.

The following snippet from the codesandbox example on integration with next.js may potentially contain a typo:

  useEffect(() => {
    // Reconnect to the session when the component is mounted
    peraWallet
      .reconnectSession()
      .then((accounts) => {
        peraWallet.connector.on("disconnect", handleDisconnectWalletClick);

        if (accounts.length) {
          setAccountAddress(accounts[0]);
        }
      })
      .catch((e) => console.log(e));
  }, []);

Issue description form ESlint:

React Hook useEffect has a missing dependency: 'handleDisconnectWalletClick'. Either include it or remove the dependency array.eslint[react-hooks/exhaustive-deps](https://github.com/facebook/react/issues/14920)

In other words, the disconnect method has to be wrapped into a useCallback or dependency array removed completely.

mucahit commented 1 year ago

@aorumbayev thanks!