marketcloud-node icon indicating copy to clipboard operation
marketcloud-node copied to clipboard

TransformError on React Native

Open SastraNababan opened this issue 8 years ago • 2 comments

I tried this module on react native and got this error : Transform Error : require() must have a single string literal arguments

simulator screen shot - iphone 8 - 2017-12-21 at 09 30 50

index.js import Marketcloud from 'marketcloud-node'

.babelrc

  "presets": ["babel-preset-expo"],
  "env": {
    "development": {
      "plugins": ["transform-react-jsx-source"]
    }
  }
}

package.json

  "name": "ecommerce",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "jest-expo": "23.0.0",
    "react-native-scripts": "1.8.1",
    "react-test-renderer": "16.0.0"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "^23.0.4",
    "faker": "^4.1.0",
    "intl": "^1.2.5",
    "marketcloud-node": "^2.2.0",
    "native-base": "^2.3.5",
    "prop-types": "^15.6.0",
    "react": "16.0.0",
    "react-native": "0.50.3",
    "react-navigation": "^1.0.0-beta.21",
    "react-redux": "^5.0.6",
    "redux-thunk": "^2.2.0"
  }
}

SastraNababan avatar Dec 21 '17 02:12 SastraNababan

Hey, for client side apps you should use our marketcloud-js sdk :) https://github.com/Marketcloud/marketcloud-js

fatmatto avatar Dec 21 '17 07:12 fatmatto

I tried marketcloud-js before. It's works on browser, but I found this error on react native simulator screen shot - iphone 8 - 2017-12-21 at 19 00 40

Probably because it use LocalStorage here. react native doesn't support LocalStorage but AsyncStorage instead do you have any suggestion ?

SastraNababan avatar Dec 21 '17 12:12 SastraNababan