Fork me on GitHub

I have a component with :route-segment ["tenant" :tenant-id] but the router won't accept it. I get "Spec failed. :tenant-id should satisfy string?". I have no clue why this happens. This is a valid route segment, and I use the same thing in other forms.


@U2APCNHCN route segments are FORCED to strings (because they must be supportable from URLs which are strings). You’re probably passing a non-string to one of the functions that does routing, and it is warning you that you’ve used non-string data in routes.


It doesn't even call the will-enter function though


The routing works fine when using Fulcro's and Fulcro RAD's routing functions, but as soon as I want to access a parametrized page by URL, as in typing it in the address bar and pressing return, it falls apart


Maybe some client middleware?


take a look at other thread @U2APCNHCN


Is the ident stringable? May be that issue, but I could be crazy


You mean the component ident? That one is :tenant/id.


But that shouldn't have any influence


are you trying to use (dr/change-route! ["tenant" "id here"]) ? can you post the stack trace?


No, I am not. In fact it even happens when I am not using dr/change-route! at all. I am using dr/deferred-route!, but it clearly doesn't even reach that statement because the log/info I've put in front never gets executed. Here's the stack trace of the other form that also doesn't work for the same reason:


Hmm actually the same happens for every form when I call the route directly as URL, instead of routing to it using dynamic-router


so it looks like a keyword is being passed to the router instead of a string


Yes, apparently. Despite me doing it exactly as described in the book. And it works when routing from inside the app. The problem is accessing the route by URL (as in having the browser make the request "from zero")


so it looks like your call to push-route! which is coming from html5 routing plugin ends up with a keyword at that location instead of a string. Ah, route history restores stuff form the URL params, and your URL has the keyword embedded in it for some reason


so when you re-use that URL, it transit decodes the params in the URL and sends them, but they have invalid data in them for whatever reason


Your problem is NOT on “load from scratch”, its somewhere where you’re setting paramters that get saved in the URL (all controls on the form/report)


Well when I go to the URL it clearly isn't embedded in the URL


Yet I still get that error


This is what my fix-route looks like:

(m/defmutation fix-route
    "Mutation. Called after auth startup. Looks at the session. If the user is not logged in,
     it triggers authentication"
  (action [{:keys [app]}]
            (hist5/restore-route! app ui/Root {})
Maybe the problem is there?


wait…that URL is the route?


where’s the ID you mention in the route segment?


you said tenant I thought


Yes, I made two forms like that, and both fail. Actually all fail


So, clearly I should have better error messages in the routing code, but if it is giving you errors related to a different route then: 1. Your “default route” might be the tenant one, which will fail because no params are possible on init 2. The URL you’ve given has no legal match, so it is doing something unexpected…


but your URL says nothing about tenant


it says “reset-password”


Yes, the other one is


and you can directly call change-route! on ["tenant" "1"] and it works?


Rather, I currently use rroute/route-to


I have more, same goes for :route-segment ["vendor" :vendor/id], it works fine with (rroute/route-to! this VendorDetailView {:vendor/id whatever-the-id-is}) but http://localhost:3000/vendor/whatever-the-id-is will fail, even though that is what ends up being in the address bar after the route-to!.


Ah, I tried it in Firefox and can actually see it change the URL to one where it includes the keyword when calling the URL with the browser.


It changed from to .


strange…I’d have to go back through the code. Not sure what’s going wrong there. It is working fine in my apps, and in the demo.


Hmm. I will also look through mine as well. Might be something with how I redirect after checking if the user is logged in. That turned out to be a massive mess to do with all the async that is going on


In all fairness, I am currently afraid to touch that part


yeah, that’s why I use a UISM for login..and when you mix in html5 history support things get interesting if you don’t keep it really clean


UISM is actually what I use for login. I copied the one from the fulcro template


so where is your extra async? Or you mean you have not taken the time to understand what is there?


Well, first I have to make sure my program waits until the UISM has figured out if the user is logged in or not, and then it has to check if the user is allowed to see the requested page depending on the session map the UISM fetched, and then do a redirect if not; but also, if and only if the user is on the landing page it has to redirect to whatever is the actual landing page for the user role.


right, so it sounds like perhaps you should have a flag that prevents all rendering (on root) until all that mess is figured out, and probably does not install history event listeners until you’ve got that as well.


Okay I created another new form with a route segment with a keyword and get the same error as well...


My route segments are either ["person-list"] or ["person" :person/id] in the first case my :ident is a function (fn [] [:component/id :person-list]) and in the latter it is :person/id .


I have a top level property in my app db that I want to load a collection of idents into, but I want the load to but cumulative (issuing multiple loads should append data and not clear the vector) - when I issue a df/load! that targets that top level property the data from the load overwrites the collection that is there - using target append-to does not work either. Is this a supported use case or will I have to use a mutation and handle the merge logic myself?


what do you mean “`append-to` does not work either”? Ah, append-to might to for to-one only. I would consider that an oversight…I’ve never used it for that. I’d accept a PR for a check in append-to that would do collections I guess. Your option right now is just to make it a post-mutation of your own. Ultimately, that’s all data targeting is.


yep - it's a collection of idents - I will try out the post mutation option for now and may look into updating the data targeting to support that.


@danvingo I do that with append-to.


It works but can cause duplicate entries when appending.


The fulcro docs for form state have this example input:

(dom/input {:value    (or name "")
            :onBlur   #(comp/transact! this [(fs/mark-complete! {:entity-ident [:person/id id]
                                                                 :field        :person/name})
what's the :root/person doing in the transaction?

jb recluse02:07:15

i think @danvingo correctly described its function below. as additional info, the book appears to call it a "follow-on read" if i understand correctly.


Yes, that’s it exactly. The original rendering model asked the user for hints on “dependent refreshes”. These are still allowed and rendering can still use them (ident-optimized), but the current best practice is to use a renderer that doesn’t need the help.