Skip to content

warn-when-not-reactive: funcall vs. component use#766

Closed
grmble wants to merge 1 commit intoday8:masterfrom
grmble:master
Closed

warn-when-not-reactive: funcall vs. component use#766
grmble wants to merge 1 commit intoday8:masterfrom
grmble:master

Conversation

@grmble
Copy link
Copy Markdown

@grmble grmble commented Oct 22, 2022

Sometimes when I write hiccup, I write (component) instead of [component] which leads to the error message from #752 if component tries to subscribe to something.

The warning as it is now talks about subscribing from event handlers or from javascript events. I found this confusing because I was pretty certain I had not touched any event handlers. But it also said "not in a reactive context" which got me on the right track.

I would argue that this is an even more likely cause for that warning and should be mentionend, especially since this is the more likely error for people new to reagent and/or re-frame. There was no other output besides this warning, just a silently malfunctioning program.

I do not care about the exact wording, but I think there should be mention of function calls vs use of a component.

I am aware of #754 and that it wants to remove the warning again. I would argue that instead of the new (when (reactive?)) there should be an if where the else branch mentions function calls vs components. I am pretty certain it does not fix this case - it just moves the check for reactive? into the function that is called from the old check location.

writing (subscribing-component) instead of [subscribing-component]
will run the subscription when the hiccup is built
instead of when it is rendered, leading to
the warning from warn-when-not-reactive
@kimo-k
Copy link
Copy Markdown
Contributor

kimo-k commented Aug 11, 2023

Hey, thanks for the PR.

I think it's extraneous, though. (component) just isn't a hiccup.

I am working on a clearer explanation for "reactive context," though, because you're right -- there's more to that concern than callbacks and reg-event. As long as we depend on reagent, this will be important to articulate, whether or not we accept 752.

@kimo-k kimo-k closed this Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants