How to deal with state arrays

Hey retool community, so basically I have a list of buttons. Upon the button click I want to add that buttons name to a state variable thats an array. How would I go about doing that? In other words upon button click entityNames gets the name of the button value. However upon button click I want that name to be added into a state variable array named 'entityArray'.

Hello thecoder! Welcome to the community forums. :slight_smile:

The first thing I notice is that state.setIn takes an array as its first value. I think that is why the query wasn't running.

Here is a quick little example where every time I press the button I add another "hi" to the temporary state. You could try something like this with different queries for each button.

These things usually take a few messages back and forth before they're resolved, so feel free to write back as many times as you need!

hey jsims, thanks for the reply. I'll give this a shot and see how it works with what i'm trying to do. So far it looks good thanks!

1 Like

My pleasure! Please, always feel free to reach out!