babeljs

Call React Parent component function from outside of the Child Component Class

有些话、适合烂在心里 提交于 2019-12-24 19:40:42
问题 Typically I do the following types of things from a Parent component this.childZ = React.createRef(); // this.handleTabs = this.handleTabs.bind(this); // bind a function //Actual function in the parent class component handleTabs = () => { ...} // I want to call this from Child Component - but outside the class (i have 3rd party javascript etc.. //In my render() <Tab eventKey={19} title="CORE SEC Z."><SectionZ ref={(secZComponent) => {window.secZComponent.handleTabs() = secZComponent}}

How to include a few node_modules package in babel-node

那年仲夏 提交于 2019-12-24 18:55:58
问题 I'm trying to include @mycompany/package1, and @mycompany/package2 to be compiled along with the rest of my code using babel-node . Since package1 and package2 are in ES6. (Also note I'm not using Webpack) In my jest config I added the below option into my jest config which works fine. When testing the code will compile the packages correctly "transformIgnorePatterns": [ "/node_modules/(?!(@mycompany)/).*/" ], But when trying to run babel-node I get errors. In my babel.config.js module

Tracing errors using karma + babel + webpack with bundles

牧云@^-^@ 提交于 2019-12-24 13:05:46
问题 Using karma + babel + webpack to run ES6 unit tests. I use a webpack bundle to locate and transpile the ES6. It all works, but whenever there is an error in any test file I get messages with no indication where the error originated, like Uncaught TypeError: Cannot read property 'querySelector' of null at /pth/to/test.bundle.js:13256 It's always /pth/to/test.bundle.js:xxxx . Any idea how to make it show more useful messages? Here's my config module.exports = function(config) { config.set({

new object in constructor from class undefined

痴心易碎 提交于 2019-12-24 09:18:48
问题 I'm creating a new object from a class in a constructor, and whenever it runs I get an error that operate is undefined in the method, though it is defined in the constructor. Operate itself is thoroughly tested and works great in a separate context so that's not the problem. I'm building it with Babel, not running it directly in Node 7.0.0 import Operate from "./operate" export default class { constructor(Schema) { this.schema = Schema this.operate = new Operate(this.schema) console.log(this

ESLint parsing error on Export statement

倾然丶 夕夏残阳落幕 提交于 2019-12-24 07:07:08
问题 I'm following a course and the author exports out a Component in the following manner: export MainContainer from './Main/MainContainer' The default correct way is export { default as MainContainer } from './Main/MainContainer' which is not as clean. The author is able to do this with a babel-eslint package, however after I installed that package I still get the lint error. Repo link File structure: Expected No ESlint errors when using export MainContainer from './Main/MainContainer' in

Keep babel class as `this` when using a member function in `setTimeout`

纵然是瞬间 提交于 2019-12-24 05:47:19
问题 I have an ES2015 class, call it Foo , which has at least two member functions, bar and baz . In bar there is a call to setTimeout whose first parameter is this.baz . Works fine up to here, I inspected it in the debugger, and this does refer to the instance of my class. (Actually since I'm using babel, I end up with a _this = this substitution beforehand but anyway the right thing is being passed into the setTimeout , confirmed.) The problem is when the setTimeout callback fires, it calls the

static keyword throwing error in grunt-babel

别等时光非礼了梦想. 提交于 2019-12-24 05:25:27
问题 I tried to trans-pile below code in try it out tab of babeljs - class aboutController{ constructor(ajaxService){ this.ajaxService = ajaxService; this.printLog(); } printLog(){ this.ajaxService.log(); } static $inject = ["ajaxService"]; } The static keyword got trans-piled to { key: "$inject", value: ["ajaxService"], enumerable: true } I then tried out grunt-babel task to automate the build. My gruntfile.js looks like this - module.exports = function(grunt){ grunt.initConfig({ pkg: grunt.file

“babelHelpers.asyncToGenerator is not a function” on React-Native 0.16.0 and 0.17.0

℡╲_俬逩灬. 提交于 2019-12-23 22:58:58
问题 I updated React-Native from 0.14.0 to 0.16.0 and from now, I have errors at runtime: Here are the npm dependencies : "dependencies": { "async": "^1.5.0", "immutable": "^3.7.6", "react-native": "^0.16.0", "react-native-contacts": "../../react-native-contacts", "react-native-contacts-rx": "^1.0.1", "react-native-gifted-messenger": "0.0.7", "react-native-i18n": "0.0.6", "react-redux": "^4.0.1", "redux": "^3.0.5", "rx": "^4.0.7" }, "devDependencies": { "babel-eslint": "^5.0.0-beta6", "eslint": "

How to load named exports with SystemJS

喜夏-厌秋 提交于 2019-12-23 20:53:04
问题 If I have a lib, say utils.js which looks like this exports.foo = function () { return 'foo'; }; exports.bar = function () { return 'bar'; }; Which can be used as follows import {foo} from './libs/utils'; console.log(foo()); Not very spectacular, but I get the feeling that this problem is the origin of the issue described in this post. Anyway I cannot get this to work in combination with SystemJS. I have to change the code to fix it import utils from './libs/utils'; console.log(utils.foo());

Why is Babel needed in an Electron project

ぐ巨炮叔叔 提交于 2019-12-23 20:39:10
问题 I'm quite confused about all the Javascript ecosystem. I'm trying Electron that seems a promising way in creating cross platform apps, leveraging the power of node and Chrome. I create a small app and used some "modern" ( this make a C# programmer laughing ) javascript concepts as lambdas, and it worked out of the box ( I supposed it was natural, since I've the latest version of node ). Then I'm trying to move next, and I see a lot of boilerplating in the examples using for example Babel. Why