File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 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';
33// Duck type promise check.
44const 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-
156function 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 {
You can’t perform that action at this time.
0 commit comments