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 3e60a49 commit d8b1ccc
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 d8b1ccc

Please sign in to comment.