Babelify throws ParseError on import a module from node_modules

That is how Browserify transforms work, transforms only have an effect directly in the module that is being referenced. If you want a module in node_modules to have a transform, you’d need to add a package.json to that module and add babelify as a transform for that module too. e.g. “browserify”: { “transform”: [ “babelify” … Read more

Typescript : underscore convention for members [closed]

Those who say, must not use the “_”, for them, here is some code from TypeScript site: class Employee { private _fullName: string; get fullName(): string { return this._fullName; } this._fullName = …… } Same question on Stackoverflow, you should have a look on it, especially the answer. For the time being, if accepted, we … Read more

How to include commonjs module in ES6 module node app?

Working with CommonJS modules is pretty straight forward. You can only do default exports from CommonJS modules. import packageMain from ‘commonjs-package’; // Works import { method } from ‘commonjs-package’; // Errors This means that all commonjs exports will live on the packageMain object, and you need to dot in to the packageMain object to pickup … Read more

Curly Brackets in Arrow Functions

The pair of braces forms a block, containing a list of statements. You need to use a return statement explicitly to make the function return something: (one) => { return oneTodo(one, action); // ^^^^^^ } If you omit the braces, the arrow function has a concise body, which consists solely of a single expression whose … Read more

ES6 — How to destructure from an object with a string key?

Destructure it by providing a valid key name like const { hello_en, ‘hello_zh-CN’: hello_zHCN, …rest } = data Working snippet var data = { hello_en: ‘hello world’, ‘hello_zh-CN’: ‘世界您好’, something: ‘nice day’, something_else: ‘isn\’t it’ } const { hello_en, ‘hello_zh-CN’: hello_zHCN, …rest } = data console.log(hello_zHCN);

How to “yield put” in redux-saga within a callback?

One possible solution, as you already mentioned, is to use channels. Here is an example that should work in your case: import { channel } from ‘redux-saga’ import { put, take } from ‘redux-saga/effects’ const downloadFileChannel = channel() export function* loadFile(id) { … const download = RNFS.downloadFile({ … // push `S_PROGRESS` action into channel on … Read more

React-native: Keep animated values in state or as class property?

It is better to follow official documentation and to use state property. There are two good reasons for that: You want to keep all things that have effect on a component render result in your state/props/context. React-Native Animated library has its own optimizationzs that allows to avoid setState calls and re-rendering on change of Animated … Read more