Skip to content

Commit

Permalink
fix: dont skip first update or plain components
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Apr 13, 2019
1 parent c5af009 commit 432e0f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/reactHotLoader.js
Expand Up @@ -46,9 +46,6 @@ const reactHotLoader = {
const proxy = getProxyById(id)

if (proxy && proxy.getCurrent() !== type) {
// component got replaced. Need to reconcile
incrementGeneration()

if (!reactHotLoader.IS_REACT_MERGE_ENABLED) {
if (
isTypeBlacklisted(type) ||
Expand All @@ -74,6 +71,7 @@ const reactHotLoader = {

registerComponent(updateProxyById(id, type, options).get(), 2)
registerComponent(type)
incrementGeneration()
}
if (isContextType({ type })) {
// possible options - Context, Consumer, Provider.
Expand Down
6 changes: 3 additions & 3 deletions test/reactHotLoader.test.js
Expand Up @@ -112,16 +112,16 @@ describe('reactHotLoader', () => {
const oldGeneration = getGeneration()
reactHotLoader.register(Div, 'Div', 'reactHotLoader.test.js')
// new thing, no change
expect(getGeneration()).toBe(oldGeneration + 0)
expect(getGeneration()).toBe(oldGeneration + 1)

reactHotLoader.register(Div, 'Div', 'reactHotLoader.test.js')
// no replacement
expect(getGeneration()).toBe(oldGeneration + 0)
expect(getGeneration()).toBe(oldGeneration + 2)

const NewDiv = () => <div />
reactHotLoader.register(NewDiv, 'Div', 'reactHotLoader.test.js')
// replacement!
expect(getGeneration()).toBe(oldGeneration + 1)
expect(getGeneration()).toBe(oldGeneration + 3)
})

it('should ignore dom elements and incomplete signature', () => {
Expand Down

0 comments on commit 432e0f8

Please sign in to comment.