Skip to content

Commit 72b88ea

Browse files
Fix use of private function from macro
This ends up expanding in the caller's namespace, which references the private `wrap-fx` and leads to a compiler warning under Figwheel. I believe Shadow is suppressing these so it wasn't caught.
1 parent 9a870be commit 72b88ea

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/helix/hooks.cljc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
local vars. Not available for the function form of a hook."
1414
#?(:clj (:require [helix.impl.analyzer :as hana])
1515
:cljs (:require
16+
[helix.impl.hooks :refer [wrap-fx]]
1617
["react" :as react]
1718
[goog.object :as gobj]))
1819
#?(:cljs (:require-macros [helix.hooks])))
@@ -117,16 +118,6 @@
117118
"Just react/useContext"
118119
react/useContext))
119120

120-
121-
;; React `useEffect` expects either a function or undefined to be returned
122-
#?(:cljs
123-
(defn- wrap-fx [f]
124-
(fn wrap-fx-return []
125-
(let [x (f)]
126-
(if (fn? x)
127-
x
128-
js/undefined)))))
129-
130121
#?(:clj
131122
(defn deps-macro-body [env deps body simple-body-ok? deps->hook-body]
132123
(cond

src/helix/impl/hooks.cljs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(ns helix.impl.hooks)
2+
3+
;; React `useEffect` expects either a function or undefined to be returned
4+
(defn wrap-fx [f]
5+
(fn wrap-fx-return []
6+
(let [x (f)]
7+
(if (fn? x)
8+
x
9+
js/undefined))))

0 commit comments

Comments
 (0)