Recommended way to call methods on a Fabric component #235
Unanswered
fbeccaceci
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So, i'm trying to create a Fabric component for the mapbox navigation sdk. I have my Fabric component that renders a map to the screen and works fine till there. Now let's say i wanna have a method that i can imperatively call from JS to move the map camera around, something like moveCameraTo(opts: CameraOptions), where CameraOptions will be a struct like this:
How would i call this method on my fabric component?
I tried implementing something with NativeCommands
And then i can invoke the command like this
But this does not work if i add the
CameraOptions
argument to the command, it throws out this errorwhich is caused by codegen when running
RCT_NEW_ARCH_ENABLED=1 pod install
So my question is first of all how do you achieve this with the new architecture so fabric and turbo modules?
Also, would it be possibile to get back a promise from
moveCameraTo
that resolves when the camera movement is done? (Given that in the native side i can get a callback for the camera movement completion i just don't know how to pass it back to the js side)I stumbled upon this article which talks about getting the reference to a component in the native side in the new architecture, i think i could get something to work this way so i can use a turbo module to call native methods which can have object arguments and use promises and then it will be the native code responsibility to find the correct component.
But then i found #29 (reply in thread) where the author is saying that due to concurrent mode it is possibile that multiple version of the same view could exists so is the approach i have mentioned safe?
Beta Was this translation helpful? Give feedback.
All reactions