This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-18
Channels
- # announcements (8)
- # aws (5)
- # babashka (69)
- # beginners (37)
- # calva (222)
- # cider (10)
- # clj-commons (8)
- # clj-kondo (69)
- # cljdoc (5)
- # clojure (62)
- # clojure-dev (23)
- # clojure-europe (37)
- # clojure-italy (2)
- # clojure-nl (6)
- # clojure-sg (6)
- # clojure-uk (5)
- # clojurescript (25)
- # clojureverse-ops (12)
- # conjure (1)
- # cursive (1)
- # fulcro (9)
- # gorilla (1)
- # graalvm (6)
- # graphql (1)
- # gratitude (1)
- # honeysql (7)
- # introduce-yourself (4)
- # jobs (1)
- # kaocha (9)
- # keyboards (4)
- # leiningen (8)
- # lsp (21)
- # malli (9)
- # music (3)
- # nextjournal (17)
- # nrepl (6)
- # off-topic (10)
- # pathom (12)
- # portal (25)
- # reagent (8)
- # releases (1)
- # specter (1)
- # xtdb (1)
I'm trying to start using some function components, but as soon as I have one and unmount it, I get an error log from react Warning: Can't perform a React state update on an unmounted component.
It isn't obvious to me what I'm doing to cause that, even from the stack trace ... any pointers on how to track it down and resolve it?
This seems suuuper annoying. Like as soon as you have a function component somewhere, it starts whining about otherwise legal/ok operations elsewhere in your app.
It isn't clear to me that something is wrong, since this seems to be a fairly common category of error (along with the error message I included) when people start using function components. I haven't found many non-trivial examples of people using functional components in reagent in general, so it is hard to judge, but I'm guessing it's hard to just dip your toes into the pool of functional components without changing the rest of your app.
I have no idea what you mean.
Here's a very simple example where f
is a function component (notice how I use it via :f>
):
(ns app.core
(:require [clojure.browser.dom]
[reagent.core :as r]
[reagent.dom]))
(defn f [x]
[:span "Hello " x])
(defn app []
(r/with-let [n (r/atom 0)]
[:div
[:f> f @n]
[:button {:on-click #(swap! n inc)}
"inc"]]))
(defn ^:export main []
(reagent.dom/render [app] (clojure.browser.dom/get-element :app)))