I'm brand new to TypeScript and I have a question about setting initializeOnMount to true. Why does it only allow me to set it to false? Here is the error message:
Type '{ children: Element; appId: string | undefined; serverUrl: string | undefined; initializeOnMount: true; }' is not assignable to type 'IntrinsicAttributes & MoralisProviderProps'.
Types of property 'appId' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.ts(2322)
The type signature for MoralisProvider is as follows:
const MoralisProvider: ({ children, appId: _appId, serverUrl: _serverUrl, jsKey, dangerouslyUseOfMasterKey, plugins, environment, getMoralis, options: { onAccountChanged },
initializeOnMount, }: MoralisProviderProps) => JSX.Element
The code snippet for mounting the component:
import MoralisProvider
import type { AppProps } from 'next/app';
import { MoralisProvider } from 'react-moralis';
function MyApp({ Component, pageProps }: AppProps) {
return (
<MoralisProvider
appId={process.env.NEXT_PUBLIC_MORALIS_APP_ID}
serverUrl={process.env.NEXT_PUBLIC_MORALIS_SERVER_ID}
initializeOnMount
>
<Component {...pageProps} />
</MoralisProvider>)
}
export default MyApp;