mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Set a proper displayName for the wrapper dynamic component.
This commit is contained in:
parent
312cf2356c
commit
93da57e1f6
|
@ -3,7 +3,7 @@ import React from 'react'
|
|||
let currentChunks = []
|
||||
|
||||
export default function dynamicComponent (promise, options = {}) {
|
||||
return class Comp extends React.Component {
|
||||
return class DynamicComponent extends React.Component {
|
||||
constructor (...args) {
|
||||
super(...args)
|
||||
|
||||
|
@ -20,6 +20,12 @@ export default function dynamicComponent (promise, options = {}) {
|
|||
|
||||
loadComponent () {
|
||||
promise.then((AsyncComponent) => {
|
||||
// Set a readable displayName for the wrapper component
|
||||
const ayncCompName = AsyncComponent.displayName || AsyncComponent.name
|
||||
if (ayncCompName) {
|
||||
DynamicComponent.displayName = `DynamicComponent for ${ayncCompName}`
|
||||
}
|
||||
|
||||
if (this.mounted) {
|
||||
this.setState({ AsyncComponent })
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue