Call JavaScript function from native code
Asked Answered
L

1

7

I have a react-native app and want to integrate it with native SDK. At some point I need to call js function which will return me data, and this call I should make from native side. Here is the flow:

  1. some iOS handler require more info
  2. native layer calls js code
  3. js code calculate/fetch required data
  4. js code return data back to native code
  5. native code receive data and continue working

Is it possible? There is a lib react-native-eval but may be there is more elegant way to do this?

Lipkin answered 14/10, 2017 at 10:9 Comment(5)
Have a look at Callbacks or Sending Events to JavaScriptBaresark
Thanks @DheerajV.S. but both of them are work in order to deliver data or notify react-native from native layer. I need to pass data in reverse orderLipkin
Hi, @Alexei Malashkevich did you find any solution for this? I am also stuck in this.Humane
@AshishSinghal did you find anything I'm also stuck here :(Stonewall
@Stonewall the correct way is to use an Event.Lipkin
C
3

There is currently no clean way of doing this. My suggestion would be to use either a Callback or an Event from native to JS to notify that there is some information needed and to then invoke a function from JS to the native code that gives the required data to the native layer.

Clientage answered 23/10, 2017 at 9:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.