Fork me on GitHub

Hi there. I’m going through the docs and noticed that in section 10.2 (React Lifecycle and Load), it is stated that

React lifecycle and load may not mix well.
I have an application where I need to load data on page load. Where should the initial data fetch operation be placed, if not lifecycle? One place I can think of is will-enter, but that requires a router and I may not have every component hooked up to a router. Thanks in advance 🙂


It’s also stated that I should be doing some checking before sending a load request. Currently the data fetched will just replace whatever is in the current state so it’s fairly simple. I just want to make sure if there’s any other recommended ways that Fulcro users tend to use.


if it's when the app boots you can issue data fetches via client-will-mount or client-did-mount the other spot to typically issue data fetches in javascript react is in :componentWillMount or :componentDidMount or the hooks equivalent. I think the section is just calling out the fact that mounting/unmounting of a component can occur more often than you anticipate, or could in the future when you update the code.

👆 1

most of the time you will have event that triggers a load, so you should think about how you can make that happen - sounds like using the dynamic router is what you'd want here, using will-enter like you mentioned


Will have a go at it. Thanks for the help 🙂


DR may be what I want here since I need to occasionally reload data as well thinking-face

Jakub Holý (HolyJak)07:04:08

> load data on page load I would do that in the fn called when the app is starting, such as my If you risk running it too often then check that it does not exist already. It is ok to use will mount. A possible problem is cascading load - when the component loads and renders, a child will start mounting and load, ... so you have a sequence of loads which is slower then loading all at once / in parallel. That is one of the problems that DR and will-enter solves. But it might not apply or matter to your case.


Is there a proper way to get the pathom env so I can run server-initiated mutations or queries? Digging through RAD's form code I found this:

(def save-form
     {:com.wsscode.pathom.connect/mutate (fn [env params] (save-form* env params))
      :com.wsscode.pathom.connect/sym    `save-form
      :com.wsscode.pathom.connect/params #{::id ::master-pk ::delta}})
Which seems to translate somehow into a callable function that calls the passed mutate fn with the env, but I haven't yet figured out where or how this happens.


You can create your own env with whatever you need in it.

🙌 1

Oh! 😂 Thanks. Maybe I should ask questions sooner, I've been trying to figure this out for hours.


Hope it helps. At one point I too was under the impression that there should be just one Pathom env and it should be retrieved to interact with Pathom. Just make them as you need.


Yep, that did the trick. Thank you!

👍 1

Release 3.5.18 of Fulcro. Adds support for :fulcro/warnings? false in component options to turn off warnings when you are happy with a component, but Fulcro warns you about it. Also changed nc so that it sets that option so you won’t see warnings about dynamically generated components. You can get them by changing it to true in the options when you call nc if you want them.

👍 4
❤️ 1