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

[Feature]: Retain data cache for parts widgets #33399

Closed
1 task done
rennzhang opened this issue May 13, 2024 · 7 comments
Closed
1 task done

[Feature]: Retain data cache for parts widgets #33399

rennzhang opened this issue May 13, 2024 · 7 comments
Assignees
Labels
Enhancement New feature or request Needs More Info Needs additional information

Comments

@rennzhang
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Summary

After switching pages, all the data from the previous page will be reloaded. Can we keep the data of all components in the page, similar to react routing caching?

Do you support this feature or help point out where you need to modify it to achieve this effect? I really need this feature, and I would appreciate it if you can provide you with any help

Why should this be worked on?

I developed my application secondary based on appsmith, and I really needed this function

@rennzhang rennzhang added the Enhancement New feature or request label May 13, 2024
@Nikhil-Nandagopal
Copy link
Contributor

@rennzhang what type of data are you looking to cache? You can use the storeValue function to save data in the local storage.

@Nikhil-Nandagopal Nikhil-Nandagopal added the Needs More Info Needs additional information label May 14, 2024
@rennzhang
Copy link
Author

Simply put, I hope that the page switch will not re-render the component. I tried some react-route caching solutions, but it didn't work

For example, page a has a table component. I enter some query conditions and search for data. Then I jump to page b and return to page a. I hope that page a will not be refreshed, that the data will not be retrieved, and that I will keep the query conditions I entered before.

@Nikhil-Nandagopal
Copy link
Contributor

@rennzhang that is currently not possible

@rennzhang
Copy link
Author

@Nikhil-Nandagopal Thank you for your answer. I spent a few days understanding the component rendering mechanism of this project, which is indeed very complex. However, I am not familiar with React enough, so I would like to ask about the general reason

@Nikhil-Nandagopal
Copy link
Contributor

The general reason is that each page is garbage collected after it's navigated away from to ensure that it doesn't consume memory. Appsmith is generally used for live dashboards where data changes and so it makes sense to fetch the data again.

@rennzhang
Copy link
Author

I fully understand that it makes sense to have him rerender. Too much caching will cause a lot of memory to consume, and maybe the data state of the component is incorrect... But I still want to ask, if I only make modifications to a few components, such as table and list components, so that it retains data when switching pages, or recovers data from cache, is there any feasible way?

I tried to store cached widgetStaticProps here. Judging from the print log, it will initially be applied to the component, but will eventually be overwritten by the original props.

@Nikhil-Nandagopal
Copy link
Contributor

@rennzhang I'm not exactly sure of that and you may have better luck asking the team on discord. I don't think there is a simple holistic solution for this and the best way would be for the user to write the logic to cache the state of the widget using storeValue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Needs More Info Needs additional information
Projects
None yet
Development

No branches or pull requests

2 participants