Native module's first example showcase incorrect usage of REACT_METHOD
. It's paired with a method without a promise as one its argument
#579
Labels
documentation
Improvements or additions to documentation
enhancement
New feature or request
Extensions
Milestone
Page url
https://microsoft.github.io/react-native-windows/docs/native-modules
Problem Description
REACT_METHOD
requires a promise as one of the arguments, but the doc sample at "1. Authoring your Native Module" has the following methodswhich, when it is paired with the following ts, isn't working:
Changing the above code as follows fixes the issue:
How I Discovered The Issue
Reading the doc, I thought 0-arity method would work like so:
However, upon debugging, an exception is thrown at
![image](https://user-images.githubusercontent.com/16918354/139518981-a87b0c40-0891-4998-bdcd-d46e60921334.png)
CxxNativeModule.cpp
instead:The intended exception message was
"Expected 1 callbacks, but only 0 parameters provided"
.Note that I did read
REACT_METHOD
was async andREACT_SYNC_METHOD
was synchronous. But thatdouble Add(double, double)
example above mislead me into writing the above code.Suggested fix
Replace
with
Info
The text was updated successfully, but these errors were encountered: