This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-05
Channels
- # aws (1)
- # beginners (57)
- # boot (3)
- # cider (6)
- # clara (49)
- # cljs-dev (47)
- # cljsjs (23)
- # clojure (144)
- # clojure-dev (2)
- # clojure-finland (1)
- # clojure-germany (1)
- # clojure-sg (1)
- # clojure-spec (25)
- # clojure-uk (245)
- # clojurescript (39)
- # core-async (3)
- # cursive (6)
- # datomic (117)
- # emacs (3)
- # fulcro (6)
- # hoplon (10)
- # jobs (7)
- # juxt (5)
- # leiningen (11)
- # om (27)
- # pedestal (4)
- # perun (2)
- # re-frame (22)
- # reagent (35)
- # ring-swagger (11)
- # shadow-cljs (333)
- # spacemacs (10)
- # specter (10)
- # sql (20)
- # vim (8)
Did you try (1) edit update the default-db in db.cljs (2) save the file (3) reload the page if not already have?
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 https://opensourcery.co.za/2017/02/12/using-semantic-ui-react-with-re-frame/
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)]
(reagent/create-class
{:display-name "generic-loading-component"
:component-did-mount
(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))
100)))
:component-will-receive-props
(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)))
:component-will-update
(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)))
:reagent-render
(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 ?
@rnagpal here is a way to do it: https://github.com/Day8/re-frame/blob/master/docs/Using-Stateful-JS-Components.md
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 []
(compojure.core/routes
(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