{"id":4452,"url":"https://github.com/artemyarulin/react-native-eval","last_synced_at":"2025-10-23T13:40:03.665Z","repository":{"id":30826331,"uuid":"34383678","full_name":"artemyarulin/react-native-eval","owner":"artemyarulin","description":"Call any JS functions from your native code","archived":true,"fork":false,"pushed_at":"2019-07-09T08:49:45.000Z","size":403,"stargazers_count":83,"open_issues_count":4,"forks_count":16,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-08T23:52:46.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artemyarulin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-22T10:17:18.000Z","updated_at":"2024-10-16T01:35:46.000Z","dependencies_parsed_at":"2022-07-08T11:44:29.076Z","dependency_job_id":null,"html_url":"https://github.com/artemyarulin/react-native-eval","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemyarulin%2Freact-native-eval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemyarulin%2Freact-native-eval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemyarulin%2Freact-native-eval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemyarulin%2Freact-native-eval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artemyarulin","download_url":"https://codeload.github.com/artemyarulin/react-native-eval/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228582487,"owners_count":17940587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:13.034Z","updated_at":"2025-10-23T13:39:58.349Z","avatar_url":"https://github.com/artemyarulin.png","language":"Java","funding_links":[],"categories":["Components"],"sub_categories":["Utils \u0026 Infra"],"readme":"# react-native-eval\n\nReact has a good [tutorial](http://facebook.github.io/react-native/docs/embedded-app-ios.html#content) how to integrate React View to already existing application, but it doesn't provide a good way if you decided to migrate some of your business logic to JS first while maintaining the same UI.\n\n## Automatic installation\n\n* `npm install react-native-eval \u0026\u0026 react-native link react-native-eval`\n\n### Manual installation `iOS`\n\n*  `pod init`. Initialize [CocoaPods](https://cocoapods.org/).\n*  Add following line to Podfile: `pod 'react-native-eval',:path =\u003e 'node_modules/react-native-eval/ios'`\n*  `pod install`.  Update the project.\n\n### Manual installation `Android`\n\n* `android/settings.gradle`\n\n```gradle\n...\ninclude ':react-native-eval'\nproject(':react-native-eval').projectDir = new File(settingsDir, '../node_modules/react-native-eval/android')\n```\n* `android/app/build.gradle`\n\n```gradle\ndependencies {\n\t...\n\tcompile project(':react-native-eval')\n}\n```\n\n* register module (in MainActivity.java)\n\n```java\n...\n\nimport com.evaluator.react.*; // \u003c--- import\n\npublic class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {\n\t...\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        mReactInstanceManager = ReactInstanceManager.builder()\n                .setApplication(getApplication())\n                .setBundleAssetName(\"index.android.bundle\")\n                .setJSMainModuleName(\"index.android\")\n                .addPackage(new MainReactPackage())\n                .addPackage(new RNMEPackage())           // \u003c- add here\n                .setUseDeveloperSupport(BuildConfig.DEBUG)\n                .setInitialLifecycleState(LifecycleState.RESUMED)\n                .build();\n\n        try {\n            Method method = getReactContextInitialize();\n            method.setAccessible(true);\n            method.invoke(mReactInstanceManager);\n            method.setAccessible(false);\n        } catch (InvocationTargetException e) {\n            e.printStackTrace();\n        } catch (IllegalAccessException e) {\n            e.printStackTrace();\n        }\n\n        setContentView(R.layout.activity_main);\n    }\n\n    private Method getReactContextInitialize() {\n        Method method;\n        try {\n            // RN 14\n            method = mReactInstanceManager.getClass()\n              .getDeclaredMethod(\"initializeReactContext\");\n        } catch (NoSuchMethodException e) {\n            method = null;\n        }\n\n        if (method == null) {\n            try {\n                // RN 15\n                method = mReactInstanceManager.getClass()\n                  .getDeclaredMethod(\"createReactContextInBackground\");\n            } catch (NoSuchMethodException e) {\n                e.printStackTrace();\n            }\n        }\n\n        return method;\n    }\n}\n```\n\nBuckle up, Dorothy\n\n# iOS\n\n*  Get a reference to `RCTBridge`, by getting it from `RCTRootView.bridge` that you have created (if you have any React Native view) or by creating `RCTBridge` manually:\n\n```objc\nRCTBridge* bridge = [[RCTBridge alloc] initWithBundleURL:[NSURL URLWithString:@\"URL_TO_BUNDLE\"]\n                      moduleProvider:nil\n                      launchOptions:nil];\nRCTRootView* view = [[RCTRootView alloc] initWithBridge:bridge moduleName:@\"app\"];\n\n// Call sync function\n[RNMEvaluator callSyncFunction:bridge\n                          name:@\"Math.pow\"\n                          args:@[@2,@2]\n                            cb:^(NSString *error, id returnValue) {\n                                if (error)\n                                    NSLog(@\"Error occured: %@\", error);\n                                else\n                                    NSLog(@\"Function returned: %@\", returnValue);\n                            }];\n\n// You can call async function as well. It has to have callback as a last argument.\n// If callback would be called with Error object then it will be converted to\n// NSString and passed as a first argument of native callback. Otherwise callback\n// value would be passed as a second parameter\n[RNMEvaluator callAsyncFunction:bridge\n                           name:@\"(function(a,b,cb) { setTimeout(function() { cb(Math.pow(a,b)) },0) })\"\n                           args:@[@2,@2]\n                             cb:^(NSString *error, id returnValue) {\n                                 if (error)\n                                     NSLog(@\"Error occured: %@\", error);\n                                 else\n                                     NSLog(@\"Function returned: %@\", returnValue);\n                             }]\n```\n\n\n# Javascript\n\n*  Call `require('react-native-eval')`, to ensure that the module is included.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartemyarulin%2Freact-native-eval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartemyarulin%2Freact-native-eval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartemyarulin%2Freact-native-eval/lists"}