Skip to content

Commit 68c2a0a

Browse files
committed
fix: allow multiple 'hot' in one file, registering only the first one
1 parent 9177aba commit 68c2a0a

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/hot.dev.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,22 @@ const hot = sourceModule => {
9090

9191
clearExceptions()
9292
const failbackTimer = chargeFailbackTimer(sourceModule.id)
93+
let firstHotRegistered = false
9394

9495
// TODO: Ensure that all exports from this file are react components.
9596

9697
return (WrappedComponent, props) => {
9798
clearFailbackTimer(failbackTimer)
9899
// register proxy for wrapped component
99-
reactHotLoader.register(
100-
WrappedComponent,
101-
getComponentDisplayName(WrappedComponent),
102-
`RHL${moduleId}`,
103-
)
100+
// only one hot per file would use this registration
101+
if (!firstHotRegistered) {
102+
firstHotRegistered = true
103+
reactHotLoader.register(
104+
WrappedComponent,
105+
getComponentDisplayName(WrappedComponent),
106+
`RHL${moduleId}`,
107+
)
108+
}
104109

105110
return createHoc(
106111
WrappedComponent,

0 commit comments

Comments
 (0)