-
Notifications
You must be signed in to change notification settings - Fork 356
Remove fbjs dependency #194
Conversation
// --- Welcome to debugging React --- | ||
// This error was thrown as a convenience so that you can use this stack | ||
// to find the callsite that caused this warning to fire. | ||
throw new Error(message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the intention here is for the debugger to pause on it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. (Not new code, just copy paste from fbjs/lib/warning)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + | ||
'You may have forgotten to pass an argument to the type checker ' + | ||
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + | ||
'shape all require an argument).' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅 Reading this kind of makes me wish you'd also copied over the format-args functionality too heh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did at first, but Babel output was super ugly and I wasn't confident enough to write the same by hand (there was both some spreading and some resting) and not break something. And we can't use ES6 because we haven't set up a pipeline here 😛
var printWarning = function() {}; | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
printWarning = function(text) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why copy this in each file? No big deal, since it's small.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about putting into prop-types/warning
but then figured someone will start using that as a "public" API. Might as well just tuck it away.
Can someone please make a release, so that all modules that depend on prop-types can get the vulnerability fix? |
|
@gaearon could you push all the git tags up for the releases? It seems that most of them (including the latest) are missing. |
Pushed a tag for the latest release. |
See reasons in facebook/react#13069.
This PR is complementary.
I chose to inline a simplified version of
warning
in two files where we use it, and replacing invariant calls withnew Error
. In case somebody relies onInvariant Violation
being the name (e.g. in tests), I inlined.name
assignments to match theinvariant
logic.Without this PR,
fbjs
would stay a transitive dep of React.