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?

5
  • Have a look at Callbacks or Sending Events to JavaScript Commented Oct 14, 2017 at 10:18
  • 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 order Commented Oct 14, 2017 at 11:23
  • Hi, @Alexei Malashkevich did you find any solution for this? I am also stuck in this. Commented Apr 17, 2019 at 10:29
  • @AshishSinghal did you find anything I'm also stuck here :( Commented Mar 11, 2021 at 5:16
  • @Imran the correct way is to use an Event. Commented Mar 31, 2021 at 10:58

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.