-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Closed
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
Description
Hi,
I am trying to update dynamic content in string template, and for that, i found an ES6 solution in stackoverflow, which works great when tested in https://es6console.com/j30fwzmy/
String.prototype.interpolate = function(params) {
const names = Object.keys(params),
vals = Object.values(params)
return (new Function(...names, `return \`${this}\`;`)(...vals))
}
const template = 'Your Code is ${char}';
const result = template.interpolate({
char: 2646765789
});
console.log(result);
But when i integrated in my app, it doesn't work as expected and throws an error Invalid character:'`', though when tried in debug mode, it works as expected.
It looks like a babel issue , not sure though, any help!!!
package.json
{
"name": "ABC",
"version": "0.0.1",
"private": true,
"dependencies": {
"html-entities": "^1.2.0",
"jwt-decode": "^2.1.0",
"qs": "^6.3.0",
"react": "16.0.0-alpha.6",
"react-addons-shallow-compare": "^15.4.2",
"react-native": "0.44.0",
"react-native-i18n": "^1.0.0",
"react-native-router-flux": "^3.38.0",
"react-native-splash-screen": "^2.0.0",
"react-native-vector-icons": "^4.0.0",
"react-redux": "^5.0.1",
"redux": "^3.6.0",
"redux-logger": "^2.7.0",
"redux-thunk": "^2.1.0",
"striptags": "^2.2.1",
"tcomb-form-native": "^0.6.1"
},
"devDependencies": {
"babel-jest": "19.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "19.0.2"
},
"jest": {
"preset": "react-native"
}
}
Metadata
Metadata
Assignees
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.