File tree 1 file changed +11
-10
lines changed
1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,6 @@ import React from 'react';
3
3
// Duck type promise check.
4
4
const isPromise = x => typeof x === 'object' && typeof x . then === 'function' ;
5
5
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
-
15
6
function createAsyncComponent ( args ) {
16
7
const {
17
8
name,
@@ -23,6 +14,16 @@ function createAsyncComponent(args) {
23
14
24
15
let id = null ;
25
16
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
+
26
27
const getResolver = ( ) => {
27
28
const resolver = resolve ( ) ;
28
29
if ( ! isPromise ( resolver ) ) {
@@ -42,7 +43,7 @@ function createAsyncComponent(args) {
42
43
if ( ! id ) {
43
44
id = nextId ( ) ;
44
45
}
45
- const Component = getComponent ( id ) ;
46
+ const Component = es6Resolve ( getComponent ( id ) ) ;
46
47
if ( Component ) {
47
48
this . state = { Component } ;
48
49
} else {
You can’t perform that action at this time.
0 commit comments