Fix tab not selecting and Error: No protocol method IDeref.-deref defined for type string: (#14194)

* Fix laziness and let defined in render
This commit is contained in:
Ibrahem Khalil 2022-10-20 14:04:13 +02:00 committed by GitHub
parent 258f92c691
commit 1aaa9acc80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 14 deletions

View File

@ -10,21 +10,22 @@
(def default-tab-size 32)
(defn tabs [{:keys [default-active on-change style]}]
(let [active-tab-id (reagent/atom default-active)]
(fn [{:keys [data size] :or {size default-tab-size}}]
(let [active-id @default-active]
[rn/view (merge {:flex-direction :row} style)
(doall
(for [{:keys [label id]} data]
^{:key id}
[rn/view {:style {:margin-right (if (= size default-tab-size) 12 8)}}
[tab/tab
{:id id
:size size
:active (= id active-id)
:on-press (fn [^js press-event id]
(reset! default-active id)
:active (= id @active-tab-id)
:on-press (fn []
(reset! active-tab-id id)
(when on-change
(on-change press-event id)))}
label]])])))
(on-change id)))}
label]]))])))
(defn- calculate-fade-end-percentage
[{:keys [offset-x content-width layout-width max-fade-percentage]}]