Fork me on GitHub
#reagent
<
2016-06-14
>
michael.heuberger03:06:30

guys, how do you look through a collection of reactions in a render block?

michael.heuberger03:06:34

this throws me an Uncaught Error: [object Object] is not ISeqable:

(let [mailboxes (subscribe [:mailboxes])])

...

(for [mailbox mailboxes]
  ^{:key (:account mailbox)} [mailbox-row mailbox])

michael.heuberger03:06:49

in the db, mailboxes is a vector

escherize03:06:36

(let [mailboxes (subscribe [:mailboxes])])

...

(for [mailbox @mailboxes] ;;<- notice @
  ^{:key (:account mailbox)} [mailbox-row mailbox])

michael.heuberger03:06:44

ah, what a rookie mistake. what is the @ for?

escherize03:06:59

subscribe returns a reaction

escherize03:06:20

and so you need to deref the reaction to see what's inside.

escherize03:06:49

Good luck 🙂

michael.heuberger03:06:36

for that i dont need luck but wisdom from guys like you 😉

tawus05:06:04

Is there a way to have a “if not found in the database, do a remote fetch” pattern in subscription. Is it even a valid pattern in re-frame ?

juhoteperi12:06:48

@jarcane: Yes, by updating state atom from onhashchange and creating reaction from that

pesterhazy16:06:08

@tom, that's explained in https://www.martinklepsch.org/posts/props-children-and-component-lifecycle-in-reagent.html -- and yes, it's not exactly straightforward with reagent

blance21:06:20

Hey guys, a quick question. I'm exporting a reagent component to be used in a React project. Is it possible to re-render on receive new props from React component?

tom23:06:58

@blance: like force render?

blance23:06:39

just regular re-render when passing in new props like vanila React does

blance23:06:09

I think reagent is using ratom and reaction to trigger re-render

blance23:06:29

but props comming from React won't be ratom

blance23:06:32

I'm kind of new to reagent/react. Not sure If I understand it correctly

tom23:06:13

I've been in the world of re-frame (it's really good) for a while so I'm fuzzy on plain reagent. You should be able to mutate the ratom inside a lifecycle method like component-will-receive-props.

blance23:06:10

yea i'm using re-frame as well.

blance23:06:47

you mean like force update on component-will-receive-props?

blance23:06:36

Another thing is that say I pass in props as <MyComponent props={this.state.props1} /> where MyComponent is the exported reagent component. Does it need to be defined as (defn my-component [props] ...) or just (defn my-component [] ...) and then get props through (r/props r/current-component)