pnjun
pnjun
SSolara
Created by pnjun on 10/11/2024 in #questions-issues
Efficiently rendering a list of components
Hey! I think i might be doing something in a non-solara way, since my app is having trouble re-rendering some compoents. I have a 'logbook' component that displays a list of entries in a loop, something like this:
@solara.component
def LogbookRender(logbook: Logbook):
appending, set_appending = solara.use_state(False) # Are we appending a new entry?

with solara.Card():
for entry in logbook:
EntryRender(entry)

if appending:
EntryRender(logbook.new_entry(), on_save=lambda: set_appending(False))
else:
solara.Button('Add Entry', on_click=lambda: set_appending(True))
@solara.component
def LogbookRender(logbook: Logbook):
appending, set_appending = solara.use_state(False) # Are we appending a new entry?

with solara.Card():
for entry in logbook:
EntryRender(entry)

if appending:
EntryRender(logbook.new_entry(), on_save=lambda: set_appending(False))
else:
solara.Button('Add Entry', on_click=lambda: set_appending(True))
The issue is that every time the user adds an entry to the list all of the previous entries are re-rendered, and this can take quite awhile for a long logbook. Is there a way to let solara know not to rerender all of the previous entries and just append the new one at the bottom of the container? I feel i might be doing something wrong but don't know what 😅 Cheers and thanks!
9 replies
SSolara
Created by pnjun on 8/31/2024 in #questions-issues
Markdown editor not entering space characters properly
When using the markdown editor, new lines will not accept spaces as input. Every time a space char is inputted, it is displayed and then immediately overwritten by whatever the user types next. However, if the space is deleted by the user by pressing backspace, the bug goes away and the editor works as intended (on that line). By looking at the raw markdown, you can see that the string " " is appended at the end of the line. It looks like the presence of that char at the end of the line fixes the bug. I tested it in both vscode and mozilla firefox (both solara server and jupyter lab) and i can reproduce in all of them. Hope this helps! Cheers
1 replies
SSolara
Created by pnjun on 8/29/2024 in #questions-issues
MarkdownEditor not displaying in vscode notebook
No description
7 replies