Skip to content

Commit

Permalink
fix: add displayNames to generated components (#731)
Browse files Browse the repository at this point in the history
Co-authored-by: Emily Marigold Klassen <forivall@users.noreply.github.com>
  • Loading branch information
forivall and forivall committed Mar 31, 2021
1 parent cba6cab commit b640c82
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/component/src/createLoadable.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,18 @@ function resolveConstructor(ctor) {
return ctor
}

const withChunkExtractor = Component => props => (
<Context.Consumer>
{extractor => <Component __chunkExtractor={extractor} {...props} />}
</Context.Consumer>
)
const withChunkExtractor = Component => {
const LoadableWithChunkExtractor = props => (
<Context.Consumer>
{extractor => <Component __chunkExtractor={extractor} {...props} />}
</Context.Consumer>
)
if (Component.displayName) {
LoadableWithChunkExtractor.displayName =
`${Component.displayName}WithChunkExtractor`;
}
return LoadableWithChunkExtractor
}

const identity = v => v

Expand Down Expand Up @@ -332,6 +339,8 @@ function createLoadable({
<EnhancedInnerLoadable forwardedRef={ref} {...props} />
))

Loadable.displayName = 'Loadable'

// In future, preload could use `<link rel="preload">`
Loadable.preload = props => {
ctor.requireAsync(props)
Expand Down

0 comments on commit b640c82

Please sign in to comment.