Commit 93da57e1 authored by Arunoda Susiripala's avatar Arunoda Susiripala

Set a proper displayName for the wrapper dynamic component.

parent 312cf235
...@@ -3,7 +3,7 @@ import React from 'react' ...@@ -3,7 +3,7 @@ import React from 'react'
let currentChunks = [] let currentChunks = []
export default function dynamicComponent (promise, options = {}) { export default function dynamicComponent (promise, options = {}) {
return class Comp extends React.Component { return class DynamicComponent extends React.Component {
constructor (...args) { constructor (...args) {
super(...args) super(...args)
...@@ -20,6 +20,12 @@ export default function dynamicComponent (promise, options = {}) { ...@@ -20,6 +20,12 @@ export default function dynamicComponent (promise, options = {}) {
loadComponent () { loadComponent () {
promise.then((AsyncComponent) => { 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) { if (this.mounted) {
this.setState({ AsyncComponent }) this.setState({ AsyncComponent })
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment