useAccount with onConnect callback functions causes maximum update depth exceeded
TudorEsan opened this issue · 3 comments
TudorEsan commented
when passing a callback function to the useAccount hook the app will continuously rerender.
this is the code that causes the bug:
export const DAppProvider = () => {
useAccount({
onConnect: () => {
console.log('Connected to StarkNet');
},
// onDisconnect: () => {
// console.log('Disconnected from StarkNet');
// },
});
return null;
};
I'm using "@starknet-react/core": "^2.8.3" and nextjs v14.1
the error i get:
Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
od-hunter commented
Hi @TudorEsan Can I be assigned this?
fracek commented
I removed the callbacks in v3 because they were causing too many issue. You should use useEffect
with the address/account in the dependency list to invoke a function when the value changes.
fracek commented
Closing because there is no way to fix it and in v3 won't be an issue.