You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to use wallet-address-validator with React Native. Below is the solution I found. If you know a better solution that would be great. I thought other people might be interested in this issue.
Here are the steps to install wallet-address-validator with React Native and Expo
yarn add wallet-address-validator
npm install -g browserify
Create a file wav-in.js that imports the wallet-address-validator module and simply exports it:
var WAValidator = require('wallet-address-validator');
module.exports = WAValidator;
Then in the terminal in the project
browserify cwav-in.js -o wav.js
This will result in an error if you put in the test code below from Wallet-Address-validator in App.js
var WAValidator = require('wallet-address-validator');
var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'BTC');
if(valid)
console.log('This is a valid address');
else
console.log('Address INVALID');
You will however, get an error along the lines “… is not a function”
On line 3837 of wav.js change “var WAValidator = require('wallet-address-validator');” to “WAValidator = require('wallet-address-validator');”
On the very last line in of wav.js add “module.exports = WAValidator;”
I was trying to use wallet-address-validator with React Native. Below is the solution I found. If you know a better solution that would be great. I thought other people might be interested in this issue.
Here are the steps to install wallet-address-validator with React Native and Expo
yarn add wallet-address-validator
npm install -g browserify
Create a file wav-in.js that imports the wallet-address-validator module and simply exports it:
var WAValidator = require('wallet-address-validator');
module.exports = WAValidator;
Then in the terminal in the project
browserify cwav-in.js -o wav.js
This will result in an error if you put in the test code below from Wallet-Address-validator in App.js
var WAValidator = require('wallet-address-validator');
var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'BTC');
if(valid)
console.log('This is a valid address');
else
console.log('Address INVALID');
You will however, get an error along the lines “… is not a function”
On line 3837 of wav.js change “var WAValidator = require('wallet-address-validator');” to “WAValidator = require('wallet-address-validator');”
On the very last line in of wav.js add “module.exports = WAValidator;”
everything should be working now
You can find a basic React Native with wallet-address-validator app at https://github.com/dbhalling/WAValidatorRN
This medium article is on point https://hackernoon.com/using-core-node-js-modules-in-react-native-apps-64acd4d07140
The text was updated successfully, but these errors were encountered: