Moralis Error v1.1.0 2

TypeError: Cannot read properties of null (reading โ€˜onโ€™)

I tried:

import Web3 from 'web3' 
import Moralis from 'moralis' 

await Moralis.enableWeb3()
const web3 = new Web3(Moralis.provider)

and

import Web3 from "web3";

await Moralis.start({
  serverUrl: "YOUR_SERVER_URL",
  appId: "YOUR_APP_ID",
  web3Library: Web3,
});
await Moralis.enableWeb3();
const web3 = Moralis.web3;

But how can I use await in a react function.

you can post/read in the thread specific to that new update: Moralis JS-SDK v1.0.0 [beta] (Ethers.js support)

Hey @Alex_Marian these are for vanilla, would be better if you wrap your App component with MoralisProvider from react-moralis library instead to initialize :raised_hands:

I done that from the beginning

import "../styles/globals.css";

import { MoralisProvider } from "react-moralis";

import { Moralis } from "moralis";

import Web3 from "web3";

function MyApp({ Component, pageProps }) {

  const serverURL = process.env.NEXT_PUBLIC_SERVERURL;

  const appID = process.env.NEXT_PUBLIC_APPID;

  Moralis.start({

    serverUrl:serverURL,

    appId:appID,

    web3Library: Web3,

  })

  return (

    <MoralisProvider appId={appID} serverUrl={serverURL}>

      <div className="containerBlack">

        <Component {...pageProps} />

      </div>

    </MoralisProvider>

  );

}

export default MyApp;

you donโ€™t need Moralis.start if you wrap with MoralisProvider also thereโ€™s no web3Library field in Moralis.start itโ€™s not the way to initialize the web3 object with the new SDK. Use these from the migration guide

await Moralis.enableWeb3();
const web3 = Moralis.web3;

I did this , it shows me the same error

InternalWeb3Provider.js?d168:134 Uncaught (in promise) TypeError: Cannot read properties of null (reading โ€˜onโ€™)
at InternalWeb3Provider.eval (InternalWeb3Provider.js?d168:134:1)
at tryCatch (runtime.js?c56e:45:16)
at Generator.invoke [as _invoke] (runtime.js?c56e:274:1)
at Generator.prototype. [as next] (runtime.js?c56e:97:1)
at asyncGeneratorStep (asyncToGenerator.js?4ec9:5:1)
at _next (asyncToGenerator.js?4ec9:27:1)

Where did you use your web3 then? :eyes: or was that you shown all your code?