Skip to content
Advertisement

Tag: ecmascript-6

Why is Babel 7 not compiling node_modules files?

I have error in IE11 SCRIPT1002: Syntax error (problem with class syntax). My simple code with 2 lines: I wan’t that my babel7 compile class into ES5 code I have tried write .babelrc file : and https://babeljs.io/docs/en/babel-plugin-transform-classes haven’t fixed too Update : I have tried use @babel/plugin-preset-es2015 which convert class in ES5 code but this package is deprecated in babel7

javascript implementation of lodash “set” method

Found this excellent code for _.get vanilla js implementation: Now I’m looking for _.set implementation, any help would be appreciated. Answer I think this could cover it: It is a bit more complex than get, because there is some logic needed to create missing parts of the path in the object, to overwrite primitive values that stand in the way,

Length of Array of Objects in JavaScript

I understand that finding the length of a JS object has been answered extensively here With one of the suggested solutions being Object.keys(myObj).length However, I’m struggling to find out how can I find the length of all properties contained on an array of objects. ie: Object.keys(users).length //3 Given the example above, How can I output a length of 9 retrieving

ES6 modules in Chrome

I’m trying to use ES6 modules in Chrome. From all the examples I’ve looked at the following seems to be the right way to do it, but when I run it in Chrome’s developer tools I get this error message… uncaught SyntaxError: Unexpected token { …highlighting the import statement in the module (script1.js, below) that’s trying to import the module.

ES6: fire React function

This is the code: What I am trying to do is to fire the updateNews code from render: But keep getting this error: Uncaught Error: this.updateNews is not a function Answer You were not calling the functuion Note: You do need to bind because you use arrow function.

Displaying images from fetch API call Node/React

Im trying display images im fetching from API btw url is defined Gallery.js with or without the regex /[blob:]{5}/gi it is only displaying the alt prop and not the image. The image is received and the get call is successful but the objectURL url is not working. Any help? Answer const {image} = this.props.photos; is equivalent to It means, “assign

Error: Cannot use GraphQLSchema “[object GraphQLSchema]” from another module or realm

Given the following code: I get this error: Error: Cannot use GraphQLSchema “[object GraphQLSchema]” from another module or realm. Ensure that there is only one instance of “graphql” in the node_modules directory. If different versions of “graphql” are the dependencies of other relied on modules, use “resolutions” to ensure only one version is installed. What’s going on? Answer This happens

Advertisement