Last active
February 12, 2019 04:53
-
-
Save attentive/a6892245133403f02f8859c7db57c022 to your computer and use it in GitHub Desktop.
How to integrate react-native-splash-screen with ClojureScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns rnss.core | |
(:require [oops.core :refer [oget ocall]] | |
[reagent.core :as r] | |
["react-native" :as RN] | |
["react-native-splash-screen" :as RNSS])) | |
;; The code below depends on the existence of a separate splash screen | |
;; layout in your app, as per the react-native-splash-screen doco. | |
;; This sample shows only how to reference the splash screen library and | |
;; activate it when your React Native app's main component is mounted. | |
;; Somewhere in your code (for re-natal code generation) | |
(js/require "react-native-splash-screen") | |
;; Some sort of React component to render (your app) | |
(def View (r/adapt-react-class (oget RN :View))) | |
;; Wrappers to manipulate splash screen | |
(defn hide-splash-screen [] (ocall (oget RNSS :default) :hide)) | |
(defn show-splash-screen [] (ocall (oget RNSS :default) :show)) | |
;; In your CLJS application's initialisation logic (Reagent sample below) | |
(defn App [] | |
(r/create-class | |
{:reagent-render | |
(fn [] | |
[View]) | |
:component-did-mount | |
(fn [this] | |
(hide-splash-screen))})) ;; Hide the splash after the App component mounts | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment