Fulcro 3.4.19-SNAPSHOT is on clojars with various additional dev-time checks to help with common mistakes:
• Emits a compiler error if a component’s query looks like an obviously wrong EQL statement
• Emits js console warnings if the initial state of your application looks wrong on initial mount
• Emits runtime warnings to js console if the app query looks wrong on set-query!
or dynamic hot code reload
Already did that
See the bottom of components.cljc
added that as part of touching up your extra warnings
it occurred to me that now that I have a component registry, it is possible to just scan for all declared components and check them
Ah, awesome! BTW I see this in my app > Component com.fulcrologic.fulcro.algorithms.form-state/FormConfig has a constant ident, but no initial state. This could cause this components props to appear as nil unless you have a mutation or load that connects it to the graph after application startup. even though I do not even use form state (though something I inherited from RAD demo and forgot to delete might). I suppose it is ok and should just be ignored but wanted to let you know in case it is an undesired side-effect.
I should add it as an exception. In this case the ID portion of that class is strange, and is mis-detected
updated snapshot
68138eb5d510eebd0d317cbb257ea9f23001e44a is the SHA
> a mutation or load that connects it to the graph after application startup
I am afraid this might be unclear to beginners. What is the load expected to do? Insert some - possibly empty but non-nil - data as in (pseudocodish) (assoc-in state (get-ident component) {})
? Or insert some data in its parent, as in (assoc-in state (conj (get-ident (get-parent component)) <the name of the corresponding parent's prop>) {})
?
target
The warning is to let you know something is wrong. The book and videos are there to help you resolve it. I’m open to better messaging, such as “See …” with a book URL if you want to make one
Heck, we can create a book section for “Understanding errors and warnings” that makes a list of them and gives a lot of detail
Then every error message could point to a URL in the book. That would be great
No, that would be absolutely awesome! I would be very happy to help with that. Something like the errors react logs...
Perhaps I could go through the codebase and make a list of all log/error and log/warn texts?
please. Then add an Appendix to fulcro-developer-guide adoc file?
I’m happy to help with the content detail, of course, but it’d be nice to have the help joining it all together
ok!
This is great. I’m very happy to help with documentation and leg-work where ever I can. I’m optimistic that an “understanding errors and warning” page will really help people get “un-stuck” when working through the getting started material.
Please. I’m swamped, so if you two want to coordinate that’s great. Any amount of putting together the errors and figuring out what to link them to (and generating those internal adoc cross-ref links) would be great. I can then just concentrate on writing a paragraph or two (or refine what you write) in the book.
Will do - I’ll coordinate with @holyjak. :thumbsup:
I am making some progress:
(g/grasp-string
(slurp (io/file "components.cljc"))
(s/cat :log #{'log/warn 'log/error}
:rest (s/+ (constantly true))))
; =>
[(log/error
"Cannot create proper fulcro component, as *app* isn't bound."
"This happens when something renders a Fulcro component outside of Fulcro's render context."
"See `with-parent-context`.")
(log/warn
"get-ident was invoked on "
(component-name x)
" with nil props (this could mean it wasn't yet mounted): "
x)
...
🙂I think a “Find in Path…” in IntelliJ would have been quicker 😉
No doubt about that. But the coolness factor is close to 0 :)
git sha cb160470072a7489719c613994a9aa9f193ad268 if you want to try it that way. Thanks to @holyjak for most of the work on the query validation.
Ok. So I am trying to learn fulcro by walking through the "getting started" chapter in the fulcro book. At section https://book.fulcrologic.com/#_mutations_on_a_normalized_database I have updated the example code. It works fine except that the mutations don't remove persons from the lists. Where can I find a complete example of this code? I.e. excluding the remote stuff for now.
I am not sure there is one. What does your code look like, can you share a link to it?
Also, have you seen https://fulcro-community.github.io/guides/tutorial-minimalist-fulcro/ and https://blog.jakubholy.net/2020/troubleshooting-fulcro/ ? Though for mutations there is perhaps not that much help.
Remember you can use REPL to get the value of the client DB I am not sure there is one. What does your code look like, can you share a link to it?
Also, have you seen https://fulcro-community.github.io/guides/tutorial-minimalist-fulcro/ and https://blog.jakubholy.net/2020/troubleshooting-fulcro/ ? Though for mutations there is perhaps not that much help.
Remember you can use REPL to get the value of the client DB (com.fulcrologic.fulcro.application/current-state app.application/app)
and try your mutation code (what you have inside action
) in the data (only replace swap!
with update
). What does happen? How does it differ from what you expected?
Thanks for the resources. I will look through them all. 🙂 I tried to debug the mutation and I got it working by modifying the parameters sent in to delete-person and the destructuring setup in delete-person itself. I think I just need to clean it up now to see how it really should be
(defmutation delete-person
"Mutation: Delete the person with :person/id
from the list with :list/id
"
[{:keys [person-id list-id]}]
(action [{:keys [state]}]
(swap! state merge/remove-ident* [:person/id person-id] [:list/id list-id :list/people])))
plus passing in the correct values to the mutation
ie (fn [person-id] (comp/transact! this [(api/delete-person {:list-id id :person-id person-id})]))]
@holyjak thanks for the tutorial tip.. it really helps to read both tutorials.
@tony.kay Do you have any plans to support namespaced keyword in incoming parameters for the template form of :initial-state? If not, then perhaps this is another opportunity for a warning or error message. I bumped into this case this afternoon - only after careful reading of 6.2.5 in the book did I notice that incoming parameters must use simple keywords. 😅