<MoralisProvider> throws error

import React from 'react';

import ReactDOM from 'react-dom';

import './index.css';

import App from './App';

import reportWebVitals from './reportWebVitals';

import { BrowserRouter, Switch } from 'react-router-dom';

import { MoralisProvider } from 'react-moralis';

ReactDOM.render(

  <React.StrictMode>

    <BrowserRouter>

    <Switch>

  <MoralisProvider appId={process.env.REACT_APP_MORALIS_APPLICATION_ID} serverUrl={process.env.REACT_APP_MORALIS_SERVER_URL} >

    <App />

  </MoralisProvider>

    </Switch>

    </BrowserRouter>

  </React.StrictMode>,

  document.getElementById('root')

);

Compiling throws this Error

./src/index.jsModule not found: Can't resolve 'react-moralis' in 'C:\Users\jesse\Documents\Code\nifty\src'

Changing 'react-moralis' to 'moralis' (moralis is what my working implementation used)throws this error

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.


P.S I have Moralis working with Moralis.Initialize... now trying to switch to MoralisProvider
1 Like

Hey @PeacanDuck

It looks like you have problem with .env file. It will work fine If you change to:

<MoralisProvider appId="Your_REACT_APP_MORALIS_APPLICATION_ID" serverUrl="Your_REACT_APP_MORALIS_SERVER_URL" >

</MoralisProvider>

Take a look at Adding Development Environment Variables In .env

Have a nice day :sunglasses:

1 Like

i already have .env setup and even if i hard code values i get the same error

Try to reinstall Moralis-React

npm install react-moralis

Or

yarn add react-moralis
1 Like

Thanks this was it had to reinstall now i can use MoralisProvider no issues

Awesome!

Happy BUIDLing :man_mechanic:

1 Like