connect icon indicating copy to clipboard operation
connect copied to clipboard

ESLint warning in next.js codesandbox example

Open aorumbayev opened this issue 1 year ago • 1 comments

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.

aorumbayev avatar Dec 04 '22 12:12 aorumbayev