There is a subtle bug introduced by the author
component:
If I navigate to /user/test
to view the posts of the user test
, and then click on “My Posts” (logged in as a user that is not test
) then the messages are correctly re-rendered but the Header remains “Messages By test”, rather than "Messages By "
I have two solutions that appear to fix this but I’m not clear on the implications of each choice as I’ve not really grokked what’s happening behind the scenes yet…
- Passing
{{{:keys [user]} :path} :parameters}
through to the inner function:
(defn author [{{{:keys [user]} :path} :parameters}]
(let [messages (rf/subscribe [:messages/list])]
(fn [{{{:keys [user]} :path} :parameters}]
[:div.content>div.columns.is-centered>div.column.is-two-thirds
[:div.columns>div.column
[:h3 "Messages By " user]
(if @(rf/subscribe [:messages/loading?])
[messages/message-list-placeholder]
[messages/message-list messages])]])))
- Remove the closure altogether:
(defn author [{{{:keys [user]} :path} :parameters}]
(let [messages (rf/subscribe [:messages/list])]
[:div.content>div.columns.is-centered>div.column.is-two-thirds
[:div.columns>div.column
[:h3 "Messages By " user]
(if @(rf/subscribe [:messages/loading?])
[messages/message-list-placeholder]
[messages/message-list messages])]]))