react-nativeclojureclojurescriptre-framere-natal

Disable RTL using ClojureScript, Re-natal and React-Native?


I'm develop an app in re-natal platform which is based on ClojureScript and React Native. I have an issue to disable RTL for my application in Android platform.

this is the code to disable RTL in react-native which works totally fine:

const ReactNative = require('react-native');

ReactNative.I18nManager.allowRTL(false); 

And I think this is the exact above code in cljs:

(def ReactNative (js/require "react-native"))

(.allowRTL (.I18nManager ReactNative) false)

However, I got this error:

"Object is not a function (evaluating 'my-app.android.core.ReactNative.I18nManager())"

react-native: "v0.50.3"

react: "16.0.0"

re-frame: "0.9.2"

clojurescript: "1.9.542"

clojure: "1.9.0-alpha16"

screenshot of error


Solution

  • I18nManager is a field (not a method) of ReactNative object. It should be accessed like this: (.-I18nManager ReactNative). So, the equivalent of

    ReactNative.I18nManager.allowRTL(false); 
    

    will be

    (.allowRTL (.-I18nManager ReactNative) false)