Mohamed-512 / Extra-Streamlit-Components

An all in one place, to find complex or just not available components by default on streamlit.
Apache License 2.0
466 stars 59 forks source link

Reduced number of re-rendering - only renders when change to `method` is recognised. #53

Closed Socvest closed 6 months ago

Socvest commented 11 months ago

I love the cookies part of this package but thought the performance was far too poor to be deployed for production. I then adopted the methodology for my package that saves data to local storage (view here). Only renders when there is a change to the method variable which I implemented in the src file.

This video shows the drastic reduction in the number of re-renders which improves component performance.

streamlit-example-2023-09-29-01-09-44

I also found that the double rendering was derived from calling the get_all() method when the class is initialised. This causes far too many rendering and removing this caused component to render once (only when called - when the app re-reruns but once not multiple time).

karunpoudel-chr commented 7 months ago

I had come here to suggest the exact same change to the python code: remove component call from init and try-except on delete. Happy to see it already here. @Mohamed-512 could you please review this PR.

Mohamed-512 commented 6 months ago

Hey all, thanks for the PR, however the change is not usable. I tested it and if a cookie is added, it will not reflect with the following rerender, and I have to refresh the page to be able to see it. Also getting an added cookie, is not possible as None is always returned. Let me know if I have missed a setup in my testing

Mohamed-512 commented 6 months ago

Fixed it in a different way. Try version 0.1.70 of the package.