Run the following in your terminal and copy the results here.
npx react-native --version
: 4.13.0npx react-native info
:We should be able to build the Native Module Library
Example using the Documentation :
Example using Githubs Repository
@getuliovdmnaweb does the example work if you change Task<string>
to IAsyncOperation<string>
? This seems like a potential docs issue.
FYI @dannyvv
Hi guys @NickGerleman @dannyvv @chrisglein @jonthysell, I have the same error as @getuliovdmnaweb , but when I create a constant using ReactConstantProvider:
This method I copied from that link:
https://github.com/microsoft/react-native-windows/blob/abee26d14b3ffed5210a97283a1353f38b0b1989/vnext/Microsoft.ReactNative.Managed.UnitTests/NativeModuleTest.cs#L498
Isn't this related to the public methods of a Windows Runtime project not being able to expose types that do not inherit from IAsyncInfo?
The NativeModuleSample builds just fine but does not match what's in the docs.
The documentation has been updated to reflect the working sample. Please re-open if the new code doesn't work.
This is the Example:
This is the Error:
@jonthysell I followed the updated documentation and the same problem still occurs.
@getuliovdmnaweb Can you post a link to your project source? It think this has less to do with the code and more to do with the structure of the solution/project files.
@jonthysell Hello, here is the link to a github repository with the example
https://github.com/getuliovdmnaweb/NativeModuleSample
@jonthysell Hello, here is the link to a github repository with the example
https://github.com/getuliovdmnaweb/NativeModuleSample
As per the docs and samples, please remove public sealed
from your module class, so that it defaults to an internal
class.
- public sealed class NativeModuleSample
+ class NativeModuleSample
Making a public WinRT class exports that class externally (to be consumed directly by any WinRT app/lib) however this requires that all public members and methods only use publicly available WinRT types. The types in Microsoft.ReactNative.Managed
(such as JSValue
and ReactPromise<>
) are not publicly available WinRT types, as Microsoft.ReactNative.Managed
is a just a Class Library, not a WinRT Library.
The expectation is that your project only exposes the ReactPackageProvider
- everything else should be internal types.