1
1
(ns react-native.fast-image
2
2
(:require
3
- [" react-native-fast-image" :as FastImage]
4
- [clojure.string :as string]
5
- [oops.core :as oops]
6
- [react-native.core :as rn]
7
- [reagent.core :as reagent]))
3
+ [" react-native-fast-image" :as FastImage]
4
+ [clojure.string :as string]
5
+ [oops.core :as oops]
6
+ [react-native.core :as rn]
7
+ [reagent.core :as reagent]))
8
8
9
9
(defn- build-source
10
10
[source]
21
21
22
22
(defn- placeholder
23
23
[{:keys [style fallback-content error? loaded?]}]
24
- [rn/view {:style (assoc style
25
- :flex 1
26
- :justify-content :center
27
- :align-items :center )}
24
+ [rn/view
25
+ {:style (assoc style
26
+ :flex 1
27
+ :justify-content :center
28
+ :align-items :center )}
28
29
(cond
29
30
(and error? fallback-content) fallback-content
30
31
error? [rn/text " X" ]
45
46
(fn [{:keys [source fallback-content on-error on-load] :as props}]
46
47
[:> FastImage
47
48
(assoc props
48
- :source (build-source source)
49
- :on-error #(on-image-error % on-error)
50
- :on-load #(on-image-loaded % on-load))
49
+ :source (build-source source)
50
+ :on-error #(on-image-error % on-error)
51
+ :on-load #(on-image-loaded % on-load))
51
52
(when (or @error? (not @loaded?))
52
53
[placeholder
53
54
{:style (js->clj (:style props))
54
55
:fallback-content fallback-content
55
56
:error? @error?
56
57
:loaded? @loaded?}])])))
57
58
58
- (defn- compare-sources [old-props new-props]
59
+ (defn- compare-sources
60
+ [old-props new-props]
59
61
(let [old-source (oops/oget old-props :source )
60
62
new-source (oops/oget new-props :source )]
61
63
(and old-source
66
68
(-> internal-fast-image
67
69
(reagent/reactify-component )
68
70
(rn/memo compare-sources)
69
- (reagent/adapt-react-class )))
71
+ (reagent/adapt-react-class )))
0 commit comments