Christos Hayward
Christos Hayward

Reputation: 5993

Can I assign a value from ReactJS Native to a Swift global variable? If so, how?

Is there any (straightforward) way to assign the value of a Swift global variable (of double_t type) from ReactJS Native JavaScript? Or (scaling back from an XY question) is there any other way to make a (floating-point) Number computed in ReactJS Native JavaScript, and access it from a .swift file?

Upvotes: 0

Views: 86

Answers (1)

Alex Wayne
Alex Wayne

Reputation: 187134

No. At least not directly.

You can make your own Native Module that React Native can call on and get data from. This allows you to write some native code that has a method that can be called to deliver the info you need. Then you write some javascript to that calls that method.

Note the Swift Specific documentation here.

Upvotes: 2

Related Questions