Fork me on GitHub
#reagent
<
2016-04-21
>
mattsfrey05:04:59

Hey, so I'm used to using react-router and am trying to setup a similar routes config with reagent. Wondering if anyone can point me in the direction of how to nest routes that link to components that will then be composed? Or is this even supported?

mattsfrey05:04:21

This port of react router seems to demonstrate what I'm trying to do:

mattsfrey05:04:41

(using secretary)

lvh16:04:13

by the way; if anyone’s using reagent with bootstrap; we built some stuff to scratch our own itches: https://www.github.com/racksec/wilson

lvh16:04:16

we’re working on some reasonably clever table stuff

sjol21:04:40

I'm encountering an issue using reagent and secretary where the url will change but nothing in the dom will change?!? has anyone encountered this before?

gadfly36121:04:15

What do your routes look like?

sjol21:04:38

(defroute "/client/:id/book" [id]
    (let [
           current-dossier (utils/get_contact_by_id id app-state)
           client-profile (:profile current-dossier)
         ]
        (swap! app-state assoc :page :book)
        (swap! app-state assoc :current-client client-profile)
      )
  )

sjol21:04:25

routes work until I get to that specific section of the app

gadfly36121:04:23

gotcha, so then what is the code that reads :page from app-state?

sjol21:04:40

it's a multi method

sjol21:04:04

(defmulti current-page #(@app-state :page))

(defmethod current-page :book [] 
    (let [local_data (r/atom {:step :step1 :booking-flow {:selected-date (js/moment)}})]
      (fn []
          [pk-booking/book  local_data app-state]
      )
      )
)

(defmethod current-page :default [] 
    (swap! app-state assoc :modal-type :appointment-option)
    [base-view app-state
      [:div "What were you looking for?"]]
)

sjol21:04:31

no not at all

sjol21:04:35

same pattern

gadfly36121:04:36

hmm i just realized i no longer embed app-state in current-page. that recipe is old, have a look at this: https://github.com/gadfly361/reagent-figwheel/blob/master/src/leiningen/new/reagent_figwheel/src/cljs/core_routes.cljs instead

gadfly36121:04:11

you can create a new app with lein new reagent-figwheel myapp +routes

gadfly36121:04:32

should be a minimal working example that you can maybe compare against

sjol21:04:21

thanks will try to add the mods to my current code

sjol21:04:56

interesting! because that component is the only one not following the other "template" structure I've setup...

sjol21:04:11

@mikethompson: it worked! Thanks! Thank you @gadfly361

gadfly36121:04:17

Glad you got it working!

tom21:04:51

Does anyone know if reagent will do self-closing tags on iframe elements? If so, is there a way to switch that off to force actual closing tags?

jeremyraines23:04:03

i tried to convert a component to the style using create-class and it doesn’t show up now. I

jeremyraines23:04:41

have googled around for 45 mins or so and can’t figure out what I am doing wrong, can anyone see a problem with this code?

jeremyraines23:04:09

(defn item
  [i]
  (reagent/create-class
    {:component-did-mount #(println "foo")
     :reagent-render
     (fn [i]
       [:div.item {:class (item-class i)}]
        [:div.attr (:retailer_name i)]]
       )}))

jeremyraines23:04:02

do you have to use that differently than a component that just is the hiccup part? before I just used it as (item i), is there some other constructor to use with this way or something?

mikethompson23:04:09

Isn't there a syntax error in that renderer?

jeremyraines23:04:43

yeah, ignore it though, i just messed it up when eliding some lines for pasting

mikethompson23:04:31

Well, it looks fine to me. So the issue must be elsewhere