Skip to content

hoodunit/ReactNativeCljs

Repository files navigation

ClojureScript on React Native for Android

Proof of concept for compiling ClojureScript for use on React Native for Android. This is simple ClojureScript JS interop duplicating the React Native example here. The original JavaScript source is in index.original.android.js and the ported ClojureScript code is in src/hello/core.cljs.

To build/run

  1. Set up project for usage: npm install && react-native android
  2. Plug in Android device (or load up emulator).
  3. Set up a reverse socket connection so your app grabs the JavaScripts from the correct place.

adb reverse tcp:8081 tcp:8081

  1. Build app and push it to the device. Enable auto-refresh in the app options.

react-native run-android

  1. Start server for serving up JS files to the device app.

react-native start

  1. Start incremental ClojureScript compilation to recompile when source files change.

./watch.sh

  1. Access logs like so:

adb logcat *:S ReactNative:V ReactNativeJS:V

  1. Hack away in ClojureScript. Saved changes will be automatically compiled to index.android.js and pushed out to the app.