Fork me on GitHub
#fulcro
<
2018-04-09
>
troglotit11:04:47

Hey! My router gets updated, but UI does not. What’s the most “right” way to fix that? I read about it in tutorial, but passing callbacks from root to every place/button seems not right

claudiu12:04:36

you can try passing to transact the reconciler instead of component and it will refresh the root, or add a follow-on read.

troglotit13:04:00

do you mean (prim/transact! Root {...})?

tony.kay15:04:20

So you're data isn't changing. Your implication is that your router is a parent of the UI, and the the UI within it didn't change. This means you didn't change the data. Pure rendering. Follow-on reads are the answer for refreshes outside of the tree branch of UI that transacted.

tony.kay15:04:29

and no, transact on a component class (e.g. Root) isn't what you should ever do. Transact needs a live component. If you wish to run it in response to a child on a parent, use computed props to pass a callback (containing a transact on a parent) through...just like you do in React everywhere.

claudiu06:04:56

@U0CKQ19AQ Is it a bad practice to store the reconciler at client start and do routing transaction on it ? Like http://book.fulcrologic.com/#_saving_a_reconciler ?

claudiu06:04:44

@U15603AQZ Sory misread, What I meant was not Root, was referring to http://book.fulcrologic.com/#_saving_a_reconciler The central function for running abstract changes in the application. Can be run with a component or reconciler. If run with the reconciler, will typically cause a root re-render.

tony.kay06:04:05

Of course that's fine, but you should only need that for thing like server push or interval updates.

tony.kay06:04:54

A router rendering issue should be solved using callbacks to the parent or abstract follow-on reads

nbdam12:04:28

Hi. I have a problem with state parameter of defcard-fulcro. When I pass in empty map initial state from components gets properly normalized. When I pass state it does not get normalized. I have tried calling get-initial-state and tree->db on state to denormalize it but it does not work correctly. I would like to have a few cards with different states but I'm not sure how to properly init state.

cjmurphy12:04:52

@nbdam You can initialise state just as you would a normal application, in the started callback.

cjmurphy12:04:10

I would think you would pretty much always leave the initial state as an empty map.

tony.kay15:04:26

Mostly true...it is sometimes useful to put a (manually normalized) map in there. The way cards work it is already an atom, which causes Fulcro to think that state is already normalized. One use for that is when you have more than one card on the same component and you want to start in different states. In that case, just use tree->db to convert your "tree" to a normalized db.

piotrek12:04:07

Hi! I am trying to integrate https://github.com/fullstackreact/google-maps-react into my Fulcro app (with shadow-cljs). I have added "google-maps-react" to my package.json but I have a hard time figuring out how to integrate GoogleApiWrapper Higher Order Component (HOC). I must admit I’m not JS expert and I am not sure how I should translate the example provided in the project’s README into Fulcro app - help and any pointers where I could learn more about this would be very appreciated 🙂

piotrek12:04:26

I tried the following:

(def ui-google-map (factory-apply Map))
(let [hoc-wrap-fn (GoogleApiWrapper #js {:apiKey "my api key"})
      gmap (ui-google-map #js {....})]
  (hoc-wrap-fn gmap))

troglotit13:04:33

you’re passing factory into HOC, but you should pass components themselves

troglotit13:04:58

(def ui-google-map
  (let [HOC (GoogleApiWrapper #js {:api "sdfsdf"})
         WrappedComponent (HOC MyMapComponent)]
    (factory-apply WrappedComponent)))

troglotit13:04:26

but I’m not 100% sure 😅

piotrek20:04:43

That was it - thank you @U15603AQZ

piotrek12:04:38

So basically I created a CLJS factory for Map React component, created an instance of that component, created a wrapper instance with my api key and then tried to wrap plain map component with that wrapper fn.

tony.kay15:04:54

So, when I play with new components, the unfortunate truth is that there are about half a dozen ways npm "libs" are distributed. See the shadow-cljs Users's Guide if you are using that compiler...if you're getting "undefined" errors and such, chances are you just didn't require is correctly.

currentoor20:04:04

anyone here use a linter in their fulcro project? thoughts? i’m considering adding it to mine

mitchelkuijpers20:04:55

We use joker, which is pretty nice

currentoor20:04:44

looks interesting

currentoor20:04:20

is it possible to make it link a directory instead of a file?

currentoor20:04:40

and did you set it up with a continuous integration tool?

mitchelkuijpers12:04:56

We have it integrated in our emacs and wrote a small bash script to check recursive directories