Is there a way to tell if an ES6 promise is fulfilled/rejected/resolved? [duplicate]

They are not part of the specification nor is there a standard way of accessing them that you could use to get the internal state of the promise to construct a polyfill. However, you can convert any standard promise into one that has these values by creating a wrapper, function MakeQueryablePromise(promise) { // Don’t create … Read more

Why does Object.assign() require a polyfill when babel-loader is being used?

Babel, via babel-loader, transpiles differences in ES6 syntax. Babel on its own does absolutely nothing to add in ES6 standard library functionality (like Object.assign). Loading the polyfill loads a separate polyfill core-js for you, but you can load any polyfill you want. Even some syntax conversions rely on specific polyfill functionality to be loads, since … Read more

Visual Studio 2015 JSX/ES2015 syntax highlighting

UPDATE (2017-02) Node Tools for Visual Studio (NTVS) has been using the Salsa analysis engine since v1.2 and using NTVS is likely the path of least resistance for JSX support. https://github.com/Microsoft/nodejstools Read (and upvote) this answer for more details: https://stackoverflow.com/a/41996170/9324 ORIGINAL ANSWER I ran into the same issue and found two solutions – one using … Read more

React JS Error: Invalid attempt to destructure non-iterable instance

I caused this error a few times because whenever I write a useState hook, which I would do often, I’m used to using an array to destructure like so: const [ state, setState ] = useState(); But my custom hooks usually return an object with properties: const { data, isLoading } = useMyCustomFetchApiHook(); Sometime I … Read more

Node –experimental-modules – Error: Cannot find module

I’m answering my own question if anybody else has this problem. It turns out in experimental mode you need to define the full path with extension. So I am trying to import index.js thinking it will know. To fix it: import express from ‘express’ import next from ‘next’ import api from ‘./src/server/api/index.js’

What is the difference between browserify/requirejs modules and ES6 modules [closed]

After playing around for a while I did get a better understanding of things, also thanks to @Andy for the blog by Addy Osmani. There are different module systems: AMD (RequireJS), CommonJS (Node) and the new ES6 module syntax (and the old ES5 Global system of course). However if you want to use those in … Read more

Create an instance of a class in ES6 with a dynamic name? [duplicate]

There are a few ways you can accomplish this… 1. Proxy Class Following from @thefourtheye’s example of maintaining a mapping of name to class, you could have a class whose job is to take the name of the desired class and proxy its instantiation: [ See it working ] Define your classes // ClassOne.js export … Read more