Hi,
Reagent makes it easy to manage the state but I couldn't find a clean and
straightforward way to manage a component tree. I have a component with
local
state that may be installed at some point (or not at all) and then may
become
unnecessary later. Say, I have a parent-component and child-component both
follow this template:
(defn component [state-atom & other-config]
(reset! state-atom initial-state)
(let [... other bindings here ...]
(fn []
... rendering ...)))
This way I can write my component like it has isolated local state, or I
can add a second arity and create my ratom there to make it really local.
But
state is not my main issue.
Question 1: I create my event handlers in the let and then assign them by
name
in rendering function to avoid having them re-created every time rendering
function is called. Does this make sense? Is it better to just define them
inline and why?
Question 2: child-component is created in the let block of
parent-component. As
far as I understand the child-component will be mounted and unmounted based
on
whether parent-component's rendering function calls its rendering function.
Is
this true?
Question 3: What is the idiomatic way to dispose of a component itself?
Should
I use an atom and reset! it to nil when I'm done?
Please note that child-component's let block defines local state (other than
the state-atom passed to it) that is not needed once the component is ready
to
be removed.
--
Kind Regards,
Atamert Ölçgen
◻◼◻
◻◻◼
◼◼◼
www.muhuk.com
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.