Hi,
I am using react-moralis
for authentication:
const { Moralis, account, isAuthenticated } = useMoralis();
const { chainId } = useChain();
useEffect(() => {
Moralis.enableWeb3();
}, [Moralis]);
useEffect(() => {
if (!account || !chainId) return;
//do some work
dispatch(action)
}, [account, chainId, dispatch]);
Is it normal that isAuthenticated=true
whereas account=undefined
?
Also, from my tests, account
and chainId
switch from defined to undefined multiple times, making my dispatched action triggered multiple times but it shouldn’t.
And sometimes I am getting the following error in the console:
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'on')
at InternalWeb3Provider.<anonymous> (InternalWeb3Provider.js:134:1)
at tryCatch (runtime.js:63:1)
at Generator.invoke [as _invoke] (runtime.js:293:1)
at Generator.next (runtime.js:118:1)
at asyncGeneratorStep (asyncToGenerator.js:5:1)
at _next (asyncToGenerator.js:27:1)
I don’t if I am doing something wrong here or if there is a real bug
Thanks for your help!