title: Having problems with reagent atom and resert! function
body: <p>Hi guys I'm new at Clojure and ClojureScript...</p>
  
  <p>I'm filling out 2 select element ... What I wonna do is update the second select depending on what option the user choose in the first select.</p>
  
  <p>This is my code:</p>
  
  <pre><code>(ns easy-recipe.components.calculate
    (:require [reagent.core :as r :refer [atom]]
              [ajax.core :as ajax]
              [reagent.session :as session]
              [easy-recipe.components.common :refer [input select button]]
              [easy-recipe.bulma.core :refer [horizontal-select horizontal-input-has-addons table columns box]]))
  
  
  (defn handler [request]
    (session/put! :categories (get-in request [:body :categories]))
    (session/put! :breads (get-in request [:body :breads]))
    (session/put! :recipes (get-in request [:body :recipes])))
  
  (defn error-hadler [request]
    (let [errors {:server-error (get-in request [:body :erros])}]
      errors))
  
  (defn get-categories-breads-recipes []
    (ajax/GET "/api/calculate"
              {:handler handler
               :error-hadler error-hadler}))
  
  (defn select-fun-wrapper [breads]
    (fn [e]
      (let [category_value (-&gt; e .-target .-value)]
        (reset! breads
                (filter
                 #(= category_value (str (% :category_id)))
                 (session/get :breads))))))
  
  (defn calculate-page []
    (get-categories-breads-recipes)
    (let [fields (atom {})
          categories (atom nil)
          breads (atom nil)
          recipe (atom nil)]
      (fn []
        (reset! categories (session/get :categories))
        ;(reset! breads (filter #(= 1 (% :category_id)) (session/get :breads)))
        [:div.container
         [box
          [horizontal-select "Category"
           [select "category" "select" @categories (select-fun-wrapper breads)]]
          [horizontal-select "Bread"
           [select "bread" "select" @breads #()]]
          [horizontal-input-has-addons "Quantity"
           [input "quantity" "input" :text "" fields]
           [button "quantity-btn" "button" "Add" #() nil]]]
         [box
          [columns
           [table ["Ingredients" "Quantity"] @recipe]
           [table ["Product" " "] [["30 Panes" "x"]]]]]])))
  
  
  </code></pre>
  
  <p>As you have noticed the breads reset! is commented... now the "select-fun-wrapper" is working fine, it updates the bread select depening on the category option selected... but if I uncomment that line the "select-fun-wrapper" will stop working (not updating the second select)... <strong>I wonna know why does it happend?</strong></p>
  
  <p>I can not leave this line commented because right now I have the problem thar the "Bread" select starts empthy... <strong>How could I fill the bread atom without using the reset! function?</strong></p>
  
  <p>Extra code (if it makes it clear):</p>
  
  <pre><code>(ns easy-recipe.bulma.core)
  
  (defn horizontal-select [label select]
    [:div.field.is-horizontal
     [:div.field-label.is-normal&gt;label.label label]
     [:div.field-body&gt;div.field.is-narrow&gt;div.control&gt;div.select.is-fullwidth
      select]])
  
  ....
  </code></pre>
  
  <pre><code>(ns easy-recipe.components.common)
  
  (defn select [id class options function]
    [:select {:id id :class class :on-change function}
     (for [opt options]
       ^{:key (opt :id)}
       [:option {:value (opt :id)} (opt :name)])])
  
  ....
  </code></pre>