Open FerVillanuevas opened 4 months ago
Hi @FerVillanuevas, just to clarify, adding this fix does not work with react native out of the box, is that correct? Additional configuration is needed on the react native side on top of this fix in order for the commerce-sdk-isomorphic
to work with react native.
Ideally things would work out of the box for all environments, browser/node/react native without additional configuration. In your manual testing, were you able to find a library that provides the same functionality as crypto
that works on all environments, potentially something like crypto-js
?
For RN there is not a Crypto library.
So we should use expo-crypto and make an alias to crypto
RN Config
Install Bable Module Resolver
Update babel.config.js
module.exports = function (api) { api.cache(true); return { presets: ["babel-preset-expo"], plugins: [ [ "module-resolver", { alias: { crypto: "expo-crypto", }, }, ], ], }; };
So we are telling to RN that the crypto lib is expo-crypto insted of crypto, the fact is expo-crypto has different methods, so we need to verify if is RN or Brower/Node then if is react native call the methods from expo.
There is an issue, navigator.product its depreacted, but other that this config works as expect and all test passed