Skip to content

Commit d7799e4

Browse files
committed
Fixes error with es6 resolver.
1 parent 9febc24 commit d7799e4

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/createAsyncComponent.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@ import React from 'react';
33
// Duck type promise check.
44
const isPromise = x => typeof x === 'object' && typeof x.then === 'function';
55

6-
// Takes the given module and if it has a ".default" the ".default" will
7-
// be returned. i.e. handy when you could be dealing with es6 imports.
8-
const es6Resolve = x => (
9-
(typeof x === 'function' || typeof x === 'object')
10-
&& typeof x.default !== 'undefined'
11-
? x.default
12-
: x
13-
);
14-
156
function createAsyncComponent(args) {
167
const {
178
name,
@@ -23,6 +14,16 @@ function createAsyncComponent(args) {
2314

2415
let id = null;
2516

17+
// Takes the given module and if it has a ".default" the ".default" will
18+
// be returned. i.e. handy when you could be dealing with es6 imports.
19+
const es6Resolve = x => (
20+
es6Aware
21+
&& (typeof x === 'function' || typeof x === 'object')
22+
&& typeof x.default !== 'undefined'
23+
? x.default
24+
: x
25+
);
26+
2627
const getResolver = () => {
2728
const resolver = resolve();
2829
if (!isPromise(resolver)) {
@@ -42,7 +43,7 @@ function createAsyncComponent(args) {
4243
if (!id) {
4344
id = nextId();
4445
}
45-
const Component = getComponent(id);
46+
const Component = es6Resolve(getComponent(id));
4647
if (Component) {
4748
this.state = { Component };
4849
} else {

0 commit comments

Comments
 (0)