Why are multi-methods not working as functions for Reagent/Re-frame?

前端 未结 4 1168
粉色の甜心
粉色の甜心 2021-02-12 12:53

In a small app I\'m building that uses Reagent and Re-frame I\'m using multi-methods to dispatch which page should be shown based on a value in the app state:

(d         


        
4条回答
  •  眼角桃花
    2021-02-12 13:39

    I don't have all the details, but apparently, when I was rendering pages like this:

    [:main.container
     [alerts/view]
     [pages @current-route]]
    

    Reagent was failing to notice that pages depended on the value of @current-route. The Chrome React plugin helped me figure it out. I tried using a ratom instead of a subscription and that seemed to work fine. Thankfully, telling Reagent/React the key to an element is easy enough:

    [:main.container
     [alerts/view]
     ^{:key @current-route} [pages @current-route]]
    

    That works just fine.

提交回复
热议问题