简体   繁体   中英

Loading @polkadot packages in react native app with expo

I am currently working on a react application to complement a web application, and have been tasked with implementing an self-sovereign identity solution using the Kilt.io protocol. This worked fine for the web app, however I am running some issues when it comes to the react native app. I initially wanted to use Expo, however the @kiltprotocol/sdk-js package depends on @polkadot packages to function, which in turn depends on the NodeJS crypto package. However, as it is a NodeJS package, the module cannot be found when trying to run my expo app. It seems like it is possible to load the crypto module using the rn-nodeify package when not using expo (although I have not actually tested this myself for this use case yet), however I was wondering if anyone knows of a solution that would work for an expo project.

Try

  1. expo install expo-crypto
  2. then create a "metro.config.js"
  3. put in
module.exports = {
    resolver: {
        extraNodeModules: {
            crypto: require.resolve('expo-crypto'),
        }
    }
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM