L
L2w ago

Alternative to mo.state() for Keeping Track of a List

Hi everyone, Here’s what I want to do: I have a list a = [] I also have b = mo.ui.text(). I want a to keep appending b.value every time I enter new text into b. The only working solution I’ve found so far is using mo.state(). I’m wondering if anyone has a better solution that doesn’t require mo.state(). Thank you! 🙏
2 Replies
Hall
Hall2w ago
Someone will reply to you shortly. In the meantime, this might help: -# This post was marked as solved by Akshay. View answer.
Shahmir
Shahmir2w ago
some_list = []
text_input = mo.ui.text(label="Enter")

text_input
some_list = []
text_input = mo.ui.text(label="Enter")

text_input
if text_input.value != "":
some_list.append(text_input.value)

some_list
if text_input.value != "":
some_list.append(text_input.value)

some_list
this should work without mo.state :>

Did you find this page helpful?