Fix issue #6300: Improve error message for unregistered callbacks.
Summary:Fix for issue #6300: Motivation: When more than one callback is registered to a native module, the error message that a user receives is not indicative of what is really happening. Closes https://github.com/facebook/react-native/pull/6436 Differential Revision: D3087551 Pulled By: tadeuzagallo fb-gh-sync-id: 93c703348dc53b75c5b507edc71754680ab5c438 shipit-source-id: 93c703348dc53b75c5b507edc71754680ab5c438
This commit is contained in:
parent
85197a0326
commit
fd2cf119b1
|
@ -192,10 +192,17 @@ class MessageQueue {
|
|||
let debug = this._debugInfo[cbID >> 1];
|
||||
let module = debug && this._remoteModuleTable[debug[0]];
|
||||
let method = debug && this._remoteMethodTable[debug[0]][debug[1]];
|
||||
if (!callback) {
|
||||
let errorMessage = `Callback with id ${cbID}: ${module}.${method}() not found`;
|
||||
if (method) {
|
||||
errorMessage = `The callback ${method}() exists in module ${module}, `
|
||||
+ `but only one callback may be registered to a function in a native module.`;
|
||||
}
|
||||
invariant(
|
||||
callback,
|
||||
`Callback with id ${cbID}: ${module}.${method}() not found`
|
||||
errorMessage
|
||||
);
|
||||
}
|
||||
let profileName = debug ? '<callback for ' + module + '.' + method + '>' : cbID;
|
||||
if (callback && SPY_MODE && __DEV__) {
|
||||
console.log('N->JS : ' + profileName + '(' + JSON.stringify(args) + ')');
|
||||
|
|
Loading…
Reference in New Issue