I have two components A and B. I want to switch between these two components on the page.
(defui A)
(defui B)
One solution is to use a parent component C:
(defui C
(render
(let [{:keys [activeView]} props]
(if (= activeView 'A')
(renderA)
(renderB)))))
The problem is query. C needs to query for both A and B, even though one of them gets displayed.
I need C to either not get involved in query, or query for either A or B only.
Are these true, or are there workarounds:
- A child component can only query its props, which is passed by its parent.
- A parent component has to query for its children so that it can pass them to children.
- Only the root component queries the
app-state
.