-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reagent-18 defscene doesn't rerender on code change #20
Comments
When you say "forcefull render", do you mean replacing this:
With just |
No, I did try that change and many more things. The issue is that the the component is not getting a rerender call at all. The I am not sure how you determine when to make a iframe rerender call, but that function needs to be exposed so that it can be manually called too when needed. |
I have an attempt at a solution. Try using Portfolio from git:
Then, where you instantiate Portfolio, add a shadow-cljs after-load hook: (defonce app
(ui/start! { ,,, }))
(defn ^:dev/after-load reload []
(ui/reload! app)) |
For some reason I am not able to start portfolio. The initial documentation page loads but I am getting these errors: 63 | (defscene
-------^------------------------------------------------------------------------
Use of undeclared Var portfolio.reagent-18/create-scene
-------------------------------------------------------------------------------- Also this in the console:
|
That's strange. I created a separate repo to isolate the issue, but did not see that error. Does this run for you? https://github.com/cjohansen/portfolio-reagent-rendering |
Reagent with react 18 has this issue where deeply nested components don't rerender on file change. To force a rerender on all parts of the component, regardless of how deeply nested it is, you need to call it as a function because then the whole component is concidered as one instead of containing react children. Example:
Of course switching between scenes loads in a component that reflects the file changes, but this is cumbersome. Best is to force react to rerender the whole component tree everytime it is mounted when in dev mode.
Perhaps also just removing this optimization from portfolio.reagent-18/component-impl function
and instead just have
That way the user can force rerender by sending down a function component if they want to.
Or perhaps this would make sense:
Perhaps if there is a function that can be called to force rerender, that would work great too. Not sure if this function exists already.
Update:
After testing these changes locally, it seems like the canvas component render function is never called on code change that is deeply nested. the
(ui/start! {:on-render #(println "on-render")})
is called concistently, but never(r.dom.client/render ...)
. So a forceful call to this whenever code changes is needed.The text was updated successfully, but these errors were encountered: