I am getting WARN re-frame: Subscribe was called outside of a reactive context.`` and I am not sure why.
I have this code:
(defn render-friend
[friend]
(let [name (:name friend)
id (:id friend)]
[:> rn/Text {:key id :style {:font-weight :normal
:font-size 16
:color :blue}}
name]))
(defn friends-list
[]
(let [friends @(subscribe [:friends])]
[:> rn/ScrollView (map render-friend friends)]))
(defn main-view
[]
[:> rn/View {:style {:background-color :white
:flex 1}}
[:> rn/View {:style {:flex 1}}
[:> MapView]]
[:> AnimatedBlock
(friends-list)]])
Animated block is a pure JS component that takes children as its only prop. It does complicated layout/styling stuff so it was easier to copy paste examples in JS.Are you sure it comes from this particular subscribe call?
Also, you probably shouldn't be calling (friends-list) like that. Try [friends-list] instead.
Why is that? It's a function. Is that a special reagent thing?
Doing that fixed the warning though!
It's the only subscribe call in the entire app
reagent's hiccup compiler uses vectors to represent elements
(friends-list) calls the function and returns the value in the parent component
[friends-list] instructs reagent to produce a new component with its own render function, using the results of (friends-list)
Understood, thanks!