Skip to content

Commit

Permalink
fix: safer reads from context consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Feb 25, 2019
1 parent b1a9bd7 commit 7942d26
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/reactHotLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ const reactHotLoader = {
registerComponent(type)
}
if (isContextType({ type })) {
// possible options - Context, Consumer, Provider.
;['Provider', 'Consumer'].forEach(prop => {
const descriptor = Object.getOwnPropertyDescriptor(type, prop)
if (descriptor && descriptor.value) {
updateFunctionProxyById(
`${id}:${prop}`,
descriptor.value,
updateContext,
)
}
})
updateFunctionProxyById(id, type, updateContext)
if (type.Provider) {
updateFunctionProxyById(`${id}:provider`, type.Provider, updateContext)
}
incrementGeneration()
}
if (isLazyType({ type })) {
Expand Down

0 comments on commit 7942d26

Please sign in to comment.