Fork me on GitHub

Did you try (1) edit update the default-db in db.cljs (2) save the file (3) reload the page if not already have?


yes, I've done both


how about > lein clean


and in repl, dev:cljs.user=> re-frame.db/app-db


if you still seeing old value, close browser and reload again


wow ok... i think it was something to do with caching


ctrl+shift+r finally got it to show my changes 😖


you have +re-frisk to go with the template? it's another way to check your app-db states


If I get new data in subscription in Third Form Reagent component, will my :component-will-receive-props or :component-will-update be called ?


I'd suggest to go with semantic-ui-react with tips from @kennethkalmer


I added console statements in various methods of component I see the render console statement called first and then the component did mount and I don’t see the component will receive props called after but the component is rendered with new re-frame subscription data


in any scenario just dispatching :initalize-db should do it, but yes i've found the caching situation problematic too


Here is the code

(fn [opts]
  (let [data-sub (re-frame/subscribe [::data-sub])
        show-loading? (reagent/atom false)]
      {:display-name "generic-loading-component"
       (fn component-did-mount [_]
         (js/console.log "In component-did-mount of loading")
         (when-not @show-loading?
           (js/setTimeout #(when-not @node-events
                             (reset! show-loading? true))
       (fn component-will-receive-props [_]
         (js/console.log "In component-will-receive-props of loading")
         (when @node-events
           (js/console.log "reset show loading to false")
           (reset! show-loading? false)))

       (fn component-will-update [_]
         (js/console.log "In component-will-update of loading")
         (when @node-events (js/console.log "reset show loading to false")
                            (reset! show-loading? false)))

       (fn [opts]
         (js/console.log "In Render of loading")
         (if @show-loading? [:div "LOADING"]
                            [show-data @data-sub opts]))})))


So in case of subscription data change does the react lifecycle not come into picture ?


(having inner and outer components)


Thanks @isak Stateful components can be done in just one component also


Is the reason to split it into two components, is to make sure react lifecycle is adhered ?


@rnagpal My understanding is yes, but in general I just wouldn't have any expectation that prop lifecycle methods would be called for normal re-frame subscription updates, because that would be an implementation detail imo. But if you pass props, then it is different.


I am having a bit of trouble here. I set up a new re-frame project from the template with the +handler option, hoping to set up a small compojure API for my re-frame app, I installed ring-json and have a handler that looks like this.

(defn api []
   (GET "/" [] {:status "OK"})))

(defroutes routes
  (context "/api/v1/" [] (api))
  (GET "/" [] (resource-response "index.html" {:root "public"}))
  (resources "/"))

(def dev-handler (-> #'routes wrap-reload))

(def handler routes)
I feel that with figwheel running and the :ring-handler option set to this handler, i would be able to hit localhost:3449/api/v1 and get back a JSON payload of {"status": "ok"} but I am instead getting a 404. Maybe It is something wrong with my understanding of Ring handlers + the compojure context, or am I supposed to be hitting another port for ring besides 3449 when running in dev mode?


sorry, @colbydehart, you'd need to have ring server be running on port 3000 on a separate console by $ lein run