Skip to content
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

Route component without re-render its view #2352

Open
ycuk opened this issue Feb 22, 2024 · 2 comments
Open

Route component without re-render its view #2352

ycuk opened this issue Feb 22, 2024 · 2 comments

Comments

@ycuk
Copy link

ycuk commented Feb 22, 2024

Describe the solution you'd like
a. A new property in existing <Route> to disable cleanup (dispose) after first render.
b. A new component that never cleanups (disposes) after first render.
c. I'm not sure if new property is suitable for <StaticRoute>

Additional context
I have dashboard index page with statistic loading from create_action and don't want to reload data every time when I back to that page. It doesn't matter resource or action, I have buttons to reload data manually or change date range, so action.dispatch() more useful. So server-side cache is not really what I need. For now my data is small and its ok with re-render, so it looks like a flash. In future will be more data and more pages like this. Also in my other project, index page too, it is photo album root if tree page, many thumbnails.

@gbj
Copy link
Collaborator

gbj commented Feb 22, 2024

The current way to do this, IMO, would be to put the create_action in the root of the app and pass it via context or props to the route. (You can define that in a function that lives with the route code, I'm not saying you need to put all the business logic in the wrong place.)

I think this is actually better than the idea of something like a <LeakRoute/>. I don't mean that sarcastically: I would genuinely want to name it something like that so it was clear that it's the same as a Box::leak() or something; you're making a one-time memory leak in exchange for static access. The logic to add the special case to the router does not seem worth it to me in exchange for the benefit, when this can already be accomplished.

@ycuk
Copy link
Author

ycuk commented Feb 27, 2024

Your way is working, but I added pagination or infinite scroll and it resets pagination or scroll position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants