Skip to content

Commit 93da57e

Browse files
committed
Set a proper displayName for the wrapper dynamic component.
1 parent 312cf23 commit 93da57e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/dynamic.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react'
33
let currentChunks = []
44

55
export default function dynamicComponent (promise, options = {}) {
6-
return class Comp extends React.Component {
6+
return class DynamicComponent extends React.Component {
77
constructor (...args) {
88
super(...args)
99

@@ -20,6 +20,12 @@ export default function dynamicComponent (promise, options = {}) {
2020

2121
loadComponent () {
2222
promise.then((AsyncComponent) => {
23+
// Set a readable displayName for the wrapper component
24+
const ayncCompName = AsyncComponent.displayName || AsyncComponent.name
25+
if (ayncCompName) {
26+
DynamicComponent.displayName = `DynamicComponent for ${ayncCompName}`
27+
}
28+
2329
if (this.mounted) {
2430
this.setState({ AsyncComponent })
2531
} else {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy