<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged react</title>
<link>https://ask.clojure.org/index.php/tag/react</link>
<description></description>
<item>
<title>MUI Select - add deselect function</title>
<link>https://ask.clojure.org/index.php/13551/mui-select-add-deselect-function</link>
<description>&lt;pre&gt;&lt;code&gt;(defn- menu-item
  [value-fn label-fn state lang index item]
(let [value (value-fn item)
    label (label-fn item lang)]
^{:key index}
[:&amp;gt; m/MenuItem {:value   value
                :data-cy (-&amp;gt; (str value) (str/lower-case) (str/replace &quot; &quot; &quot;-&quot;) (str &quot;-menu-item&quot;))}
 [:&amp;gt; m/Checkbox {:checked (= (value-fn state) value)}]
 [:&amp;gt; m/Typography {} label]
 ]))
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;(defn select
  [{:keys [data state-fn disabled? label value-fn label-fn data-cy variant]}]
  (let [rf-lang   (rf/subscribe [:current-language])
        label-fn1 (or label-fn (fn [item lang] (value-fn item)))]
    (fn [{:keys [data state-fn disabled? label value-fn data-cy variant]}]
      (let [lang  @rf-lang
            state (state-fn)
            props (cond-&amp;gt;
                    {:select      true
                     :full-width  true
                     :SelectProps {:MenuProps    {:getContentAnchorEl nil}
                                   :render-value (fn [items]
                                               (if label-fn
                                                 (label-fn state lang)
                                                 (map identity items)))
                               :data-cy      data-cy}
                 :value       (or (value-fn state) &quot;&quot;)
                 :on-change   (fn [e]
                                (let [selected (.. e -target -value)]
                                  (state-fn (first (filter #(= selected (value-fn %)) data)))))
                 :label       (i18n/translation label lang)
                 :disabled    disabled?}
                variant (assoc :variant variant))]
    [:&amp;gt; m/TextField props (map-indexed (partial menu-item value-fn label-fn1 state lang) data)]))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I have the following piece of code to create a dropdown list with items that have a checkbox next to them. The problem is that the checkbox cannot be removed. When the user clicks on an already selected checkbox, nothing happens. And in this case, it should become deselect.&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13551/mui-select-add-deselect-function</guid>
<pubDate>Wed, 13 Dec 2023 11:43:41 +0000</pubDate>
</item>
<item>
<title>Are there any active projects to enable incremental static regeneration for server-rendered cljs/React?</title>
<link>https://ask.clojure.org/index.php/11778/active-projects-enable-incremental-regeneration-rendered</link>
<description>&lt;p&gt;Modern React frameworks like Next.js allow for incremental static regeneration of pages (&lt;a rel=&quot;nofollow&quot; href=&quot;https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration&quot;&gt;https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration&lt;/a&gt;). I’ve looked at projects like Rum which do server-side rendering directly via the JVM, and have seen thheller’s proof of concept for using cljs directly with Next (&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/thheller/next-cljs&quot;&gt;https://github.com/thheller/next-cljs&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Are there any efforts to enable incremental static regeneration for clj/cljs servers with a JVM-based backend? Or, have there been any efforts beyond thheller’s proofs of concept with Gatsby and Next to make an extremely-thin wrapper/compiler library for cljs + React designed explicitly to work well with existing Node.js frameworks?&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11778/active-projects-enable-incremental-regeneration-rendered</guid>
<pubDate>Mon, 18 Apr 2022 20:28:39 +0000</pubDate>
</item>
<item>
<title>Any good resource to learn React with ClojureScript</title>
<link>https://ask.clojure.org/index.php/9561/any-good-resource-to-learn-react-with-clojurescript</link>
<description>&lt;p&gt;I have experience with react using JavaScript. My company uses ClojureScript React, so just trying to find some good resource. I have googled but did not find any clear answer. &lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9561/any-good-resource-to-learn-react-with-clojurescript</guid>
<pubDate>Wed, 02 Sep 2020 15:14:37 +0000</pubDate>
</item>
<item>
<title>Figwheel/shadow-cljs hot reloading</title>
<link>https://ask.clojure.org/index.php/8261/figwheel-shadow-cljs-hot-reloading</link>
<description>&lt;p&gt;Is there a way to re-render only the affected parts of the app on hot reload?&lt;/p&gt;
&lt;p&gt;Figwheel docs says only about re-mounting the whole app (in which case you lose all the local  state of components): &lt;a rel=&quot;nofollow&quot; href=&quot;https://figwheel.org/docs/hot_reloading.html#re-rendering-ui-after-saving-a-file&quot;&gt;https://figwheel.org/docs/hot_reloading.html#re-rendering-ui-after-saving-a-file&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Haven't found anything on that matter in shadow-cljs docs. All the apps I've seen so far either not re-render on hot reload at all or do the re-mount.&lt;/p&gt;
&lt;p&gt;So, what are the obstacles with comparing pre- and post- hot reload VDOMs and updating the DOM based on this diff? Or is it already implemented?&lt;/p&gt;
&lt;p&gt;While Figwheel/shadow-cljs are independent of React/VDOM, that's expected that they don't implement such behaviour, but maybe there's some lib or well-defined approach to do so?&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8261/figwheel-shadow-cljs-hot-reloading</guid>
<pubDate>Tue, 30 Jul 2019 07:47:26 +0000</pubDate>
</item>
</channel>
</rss>