Moralis React Native, Crypto Dep Error

Change it to:

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
  resolver: {
    sourceExts: ['jsx', 'js', 'ts', 'tsx'],
  },
};

No errors but app wont start, doesnt go past the splash screen

Restarted metro now im getting this:
Error: Unable to resolve module http from /Users/u/app/node_modules/web3-providers-http/lib/index.js: http could not be found within the project or in these directories:
node_modules
…/node_modules

Install react-native-crypto instead of crypto-js

And then change

var CryptoJS = require('react-native-crypto')

My bad, we needed to do this from the beginning.

npm uninstall crypto-js

npm i react-native-crypto --save

Still getting this error, I restarted everything
Error: Unable to resolve module http from /Users/u/app/node_modules/web3-providers-http/lib/index.js: http could not be found within the project or in these directories:
node_modules
…/node_modules

After npm i http:

Error: While trying to resolve module http from file /Users/u/app/node_modules/web3-providers-http/lib/index.js, the package /Users/u/app/node_modules/http/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/u/app/node_modules/http/index. Indeed, none of these files exist:

Can you upload it to github and send me a link in DM?

Is this how to connect to moralis on react native:

const Moralis = require(‘moralis/react-native.js’)

Moralis.initialize(‘XXXXXXXXXXXX’);

Moralis.serverURL = ‘https://XXXXXXXXX.moralis.io:XXXX/server’;

You should install React Moralis:

npm install react-moralis --save

Take a look at React Moralis Docs
index.js file:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { MoralisProvider } from 'react-moralis';

const theme = extendTheme({
  config: {
    initialColorMode: 'dark',
  },
});

const appId = 'YOUR_APP_ID';
const serverUrl = 'YOUR_SERVER_URL';

ReactDOM.render(
  <React.StrictMode>
    <MoralisProvider appId={appId} serverUrl={serverUrl}>
        <App />
    </MoralisProvider>
  </React.StrictMode>,
  document.getElementById('root'),
);

For developing on React Native please use Moralis React SDK

The difference for developing on React Native is for metamask authentication and all that , you would need to do extra steps

I don’t need metamask i just want to access the data only

this is the index.js, exactly do I fix it for RN:

/**

  • @format

*/

import {AppRegistry} from ‘react-native’;

import App from ‘./App’;

import {name as appName} from ‘./app.json’;

AppRegistry.registerComponent(appName, () => App);

Also how do i import Moralis into the App.js?

I’m experiencing a similar problem is there a solution or can we not use Moralis with react native currently?

Hi @clb @omni

Official library for react-native coming later this year. But now you can use Moralis React SDK for developing on React Native, it might not be easy if you don’t have react-native experience, but it should work.

Hi Yomoo,

I am currently trying to transition from Next.js to React Native and I have a problem with Metamask and or Moralis authentication. I use Expo and for some reason, it compiles perfectly in the browser but it does not on my phone. The current error is:
…\node_modules\moralis\lib\browser\EventEmitter.js: events could not be found within the project or in these directories:
node_modules\moralis\node_modules
node_modules

Is there any additional steps I forgot or need to add for Native?

Hey @mattmorvai

Take a look at:

But If it will not solve the problem - please open a new topic and provide us more information :raised_hands: and we will start to figure out the details :man_mechanic:

REACT NATIVE SUPPORT IS HERE! https://www.youtube.com/watch?v=FRilwynjW1c