Fork me on GitHub
#clojure-uk
<
2020-03-25
>
dharrigan06:03:30

Good Morning!

zyxmn07:03:11

Good morning . Great weather for the next 2 weeks

thomas08:03:49

morning lovely people

dharrigan08:03:10

Yes, lovely spring-like conditions outside.

dominicm08:03:28

I guess I'll watch it from the window

πŸ˜„ 4
guy08:03:48

You can still go out to get food and exercise

guy08:03:06

Morning all

guy08:03:33

I'm really glad its so sunny, if it was grey and rainy i think that would negatively impact people a lot more

πŸ‘ 4
dominicm08:03:28

I know. I'm just teasing, sorry :)

guy08:03:09

haha its ok! I just wasn't sure πŸ˜„

Ben Hammond09:03:10

do any of you use React Router

Ben Hammond09:03:28

I'm trying to extract the value of a path param from a Route; all the children components are function-as-React-Components I can see that the

{:history :location :match}
exist as Props in my component but sinceits a component-as-function, I don't know if I can access them

Ben Hammond09:03:19

I can cobble something together with a `

:render
(fn [m]
...
js/m.match.params.id)
but it doesn't feel quite right

Ben Hammond09:03:52

React DevTools tells me that the thing I want exists as a Prop

Ben Hammond09:03:13

but I don't know how to access the Prop from within the component function

Ben Hammond09:03:41

theres an assumption that component props are just params passed in to the function

Ben Hammond09:03:17

hmmm. its a Router.Provider div that has the Props in it

Gulli09:03:44

Morning peeps

tragiclifestories10:03:58

@ben.hammond Looks like react-router has hooks for this now, if you'd prefer that https://reacttraining.com/react-router/web/api/Hooks

πŸ‘ 4
Ben Hammond10:03:38

ah. that's what I was missing!

Ben Hammond10:03:00

I want the matches, and the hook is called useHistory

Ben Hammond10:03:16

but I bet it returns the whole data structure

Ben Hammond10:03:02

so this works for me

(defn with-matches []
  (let [m (router/useRouteMatch "/board/:id")]
    (.log js/console "m is " m)
    [:h2 "params.id: " js/m.params.id]))

Ben Hammond10:03:21

called from within

[:> router/Switch
      [:> router/Route {:path "/board"}
       [with-matches]]

πŸ‘ 4
Ben Hammond10:03:29

slightly niggles that I have to specify the path twice but on a worldwide scale not a biggie

tragiclifestories10:03:21

Yeah, just be aware of the hooks rules and all that jazz (ie, never invoke a hook in an if or a loop)

tragiclifestories10:03:32

not a problem there obviously

Ben Hammond10:03:05

well it IS within a Router switch

Ben Hammond10:03:44

my plan B is to encase the :render property in syntactic sugar something like

(defn with-route
  [props child]
  [:> router/Route
   (assoc props
     :render
     (fn [m]
       (.log js/console "m is " m)
       (uix/as-element [child m])))])

tragiclifestories10:03:00

wow, they've really gone hooks-mad

tragiclifestories10:03:13

react-router knowledge famously ages badly πŸ˜…

Ben Hammond10:03:08

Just for the record, this seems to work just fine

(defn with-params []
  (let [m (router/useParams)]
    (.log js/console "m is " m)
    [:h2 "params.id: " js/m.id]))

...
     [:> router/Switch
      [:> router/Route {:path "/board/:id"}
       [with-params]]

Adrian Smith12:03:28

hey Bristol's Clojure meetup is online tonight (6pm - 8pm): https://www.meetup.com/Bristol-Clojurians/events/zdfnqrybcfbhc/ if you'd like to join us we're in #bristol-clojurians πŸ™‚

πŸ‘ 12
clj 4
Gulli14:03:21

@UCJCPTW8J Hi, will this be recorded? I'm not available at that time but really interested in this.

Adrian Smith17:03:48

I don't think that's the initial plan, but we should consider it once we find our feet

Gulli17:03:17

If your ok with it, I might screen record this to view later tonight

πŸ‘ 4
Gulli17:03:44

No way I can watch until my daughter is asleep

joetague15:03:50

cool just got an email "Tomorrow we will officially relaunching http://skillsmatter.com" good to see

πŸ‘ 12
dharrigan21:03:21

What do people use to run standalone jars on a unix platform and have that service restart if the platform is restarted?

Eamonn Sullivan09:03:14

We use systemd on all our services. We use spec files to create rpms for centos7 and one of the "%post" commands is systemctl enable /usr/lib/<some-application>/<some-application>.service The service file itself has an ExecStart command like java -jar /usr/lib/<some-application>... and Restart set to always.

dharrigan21:03:26

supervisord?

folcon23:03:35

Anyone got experience with lacinia subscriptions? Been tearing my hair out trying to work out how this is supposed to work…

folcon23:03:55

@dharrigan I’ve used systemd, and I’ve also known a few people to just use nohup <run jar> & or run it inside screen

dharrigan23:03:55

Nohup sounds good enough for my use case