Skip to content

Commit

Permalink
suppress warnings, #804
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Jan 19, 2018
1 parent 8802f03 commit 8e25a76
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 12 deletions.
19 changes: 16 additions & 3 deletions examples/styled-components/src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hot } from 'react-hot-loader'
import { hot, setConfig } from 'react-hot-loader'
import * as React from 'react'
import styled from 'styled-components'
import emoStyled from 'react-emotion'
Expand All @@ -12,14 +12,27 @@ const SmallText = emoStyled('div')`
font-size: 22px;
`

const indirect = {
element: () => (
<SmallText>
hidden2 <Counter />
</SmallText>
),
}

const aNumber = 10

const App = () => (
<h1>
<BigText>Hello, world.</BigText>
<BigText>1.Hello, world!! {aNumber} </BigText>
<br />
<SmallText>Hello, world.</SmallText>
<SmallText>2.Hello, world---.</SmallText>
<br />
<Counter />
<indirect.element />
</h1>
)

setConfig({ logLevel: 'debug' })

export default hot(module)(App)
20 changes: 14 additions & 6 deletions packages/react-hot-loader/src/reconciler/hotReplacementRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,20 @@ const mergeInject = (a, b, instance) => {
if (flatA.length === flatB.length) {
return mapChildren(flatA, flatB)
}
logger.warn(
`React-hot-loader: unable to merge `,
a,
'and children of ',
instance,
)
if (
flatB.length === 0 &&
flatA.length === 1 &&
typeof flatA[0] !== 'object'
) {
// terminal node
} else {
logger.warn(
`React-hot-loader: unable to merge `,
a,
'and children of ',
instance,
)
}
return NO_CHILDREN
}

Expand Down
8 changes: 5 additions & 3 deletions packages/react-stand-in/src/createClassProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,11 @@ function createClassProxy(InitialComponent, proxyKey, wrapResult = identity) {
const displayName = getDisplayName(CurrentComponent)
ProxyFacade.displayName = displayName

safeDefineProperty(ProxyComponent, 'name', {
value: displayName,
})
if (ProxyComponent) {
safeDefineProperty(ProxyComponent, 'name', {
value: displayName,
})
}

savedDescriptors = transferStaticProps(
ProxyFacade,
Expand Down
15 changes: 15 additions & 0 deletions packages/react-stand-in/test/static-descriptor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,18 @@ describe('static descriptor', () => {
})
})
})

describe('static functional descriptor', () => {
it('shout pass propTypes', () => {
const TestComponent = () => <div />
TestComponent.propTypes = {
property: 42,
}
TestComponent.displayName = 'Testing'
const proxy = createProxy(TestComponent)
const Proxy = proxy.get()

expect(Proxy.propTypes.property).toBe(42)
expect(Proxy.displayName).toBe('Testing')
})
})

0 comments on commit 8e25a76

Please sign in to comment.