Open irgolic opened 3 months ago
Ah yeah I think adding key
to gr.State
like we have for the components makes sense -- cc @aliabid94
btw @irgolic can you share a small code snippet so that we can use to test?
Sure, here's a quick demo:
import gradio as gr
with gr.Blocks() as demo:
my_state = gr.State([])
@gr.render(inputs=[my_state])
def _(rows):
for r in rows:
gr.Textbox(r)
button = gr.Button("+")
button.click(lambda l: l + ["row"], my_state, my_state)
demo.launch()
Any updates on this? Anything I can do to help expedite?
Hi @irgolic - we're busy preparing a 5.0 major release. Contributions on this are welcome - we'd be happy to review any PRs :) 🙏
Hi @freddyaboulton, good luck with the release!
I'd love to contribute, could you review my other outstanding PR first?
Is your feature request related to a problem? Please describe.
I have some components where input variables are specified, they're generated by a
gr.render
decorator though, so the actual values are stored in a state. The state does not persist reloads, and I need to input the values every time it reloads.The same does not hold for normal textboxes – those persist just fine.
Describe the solution you'd like
Upon hot reload,
gr.State
values should stay what they are. Perhaps akey
argument should be added togr.State
to facilitate this.