Skip to content

Commit

Permalink
unmount-fiksi
Browse files Browse the repository at this point in the history
  • Loading branch information
Jussi Jartamo committed May 16, 2022
1 parent 23b2fb4 commit bcb11c5
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,27 @@
(let [collapsed (reagent/atom true)
scroll-height (reagent/atom nil)
listener (reagent/atom nil)
mounted? (reagent/atom false)
timeout (atom nil)
debounced-resize (fn [component]
(js/clearTimeout @timeout)
(reset!
timeout
(js/setTimeout #(set-markdown-height component scroll-height) 200)))
(js/setTimeout (fn []
(when @mounted?
(set-markdown-height component scroll-height))) 200)))
lang (re-frame/subscribe [:application/form-language])]
(reagent/create-class
{:component-did-mount
(fn [component]
(reset! mounted? true)
(set-markdown-height component scroll-height)
(reset! listener #(debounced-resize component))
(.addEventListener js/window "resize" @listener))

:component-will-unmount
(fn [_]
(reset! mounted? false)
(.removeEventListener js/window "resize" @listener))

:component-did-update
Expand Down

0 comments on commit bcb11c5

Please sign in to comment.