How my react js code can interact with existing Obj-C logic? -


i have existing obj-c project rich business logic. wanna try using react native on particular screen (i mean view controller in terms of cocoa), every example see in repo contains logic in javascript. how can treat react native rendering, pass user actions objective-c code?

edit 31 march 2015:

native view module not seem solution, because native modules instanciated react code. if want use created view model view controller, need have singleton, shared state on side. think bad.

it's not possible react views call native methods directly without going through javascript, unless create custom native view plugins literally onscreen.

your best bet create custom native module exports native methods want call, write minimal react javascript application nothing except forward touch events views module calling methods.

if need communicate js application, module can either use callbacks passed exported methods, or broadcast events js code can observe.

to out of react native though, i'd recommend try keep view , controller logic in js part, , expose business logic native side. otherwise lose benefits of rapid reloading test changes, etc.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -