Skip to content

Commit b640c82

Browse files
authored
fix: add displayNames to generated components (#731)
Co-authored-by: Emily Marigold Klassen <[email protected]>
1 parent cba6cab commit b640c82

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packages/component/src/createLoadable.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ function resolveConstructor(ctor) {
2626
return ctor
2727
}
2828

29-
const withChunkExtractor = Component => props => (
30-
<Context.Consumer>
31-
{extractor => <Component __chunkExtractor={extractor} {...props} />}
32-
</Context.Consumer>
33-
)
29+
const withChunkExtractor = Component => {
30+
const LoadableWithChunkExtractor = props => (
31+
<Context.Consumer>
32+
{extractor => <Component __chunkExtractor={extractor} {...props} />}
33+
</Context.Consumer>
34+
)
35+
if (Component.displayName) {
36+
LoadableWithChunkExtractor.displayName =
37+
`${Component.displayName}WithChunkExtractor`;
38+
}
39+
return LoadableWithChunkExtractor
40+
}
3441

3542
const identity = v => v
3643

@@ -332,6 +339,8 @@ function createLoadable({
332339
<EnhancedInnerLoadable forwardedRef={ref} {...props} />
333340
))
334341

342+
Loadable.displayName = 'Loadable'
343+
335344
// In future, preload could use `<link rel="preload">`
336345
Loadable.preload = props => {
337346
ctor.requireAsync(props)

0 commit comments

Comments
 (0)