Skip to content

Commit

Permalink
Fix issue with isValidElementType invariant check crashing on valid t…
Browse files Browse the repository at this point in the history
…ype with circular structure
  • Loading branch information
Andarist committed Dec 12, 2018
1 parent 775f1ac commit 1fe203a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/connectAdvanced.js
Expand Up @@ -5,6 +5,14 @@ import { isValidElementType } from 'react-is'

import { ReactReduxContext } from './Context'

const stringifyComponent = Comp => {
try {
return JSON.stringify(Comp)
} catch (err) {
return String(Comp)
}
}

export default function connectAdvanced(
/*
selectorFactory is a func that is responsible for returning the selector function used to
Expand Down Expand Up @@ -86,7 +94,7 @@ export default function connectAdvanced(
invariant(
isValidElementType(WrappedComponent),
`You must pass a component to the function returned by ` +
`${methodName}. Instead received ${JSON.stringify(WrappedComponent)}`
`${methodName}. Instead received ${stringifyComponent(WrappedComponent)}`
)
}

Expand Down

0 comments on commit 1fe203a

Please sign in to comment.