Custom Components - Confused about properties

Hi Thunkable folks,
I have started playing with the new-ish Custom Components features. There’s one thing that’s throwing me off:
Is there a way for a custom component to set its own property dynamically using blocks?

I can:

  • Set a property from an outside project that is using the component.
  • React to a change in the property within the component.
  • Set a “default value” for the property.

But when a property is added to a custom component, I’m only given a block for accessing the property, not one for setting it:
2024-04-12 13_04_07-Window

This means that properties can only be used for information going into the component, they cannot be used for information out of the component. That feels weird though, because lots of components have variables that we’d like to expose externally.

Without the option to internally set a property, it seems like the way to do this is to not use properties at all and instead to use methods for sending a value into component and events for sending a value out of component. That’s OK if it needs to be a very event-driven type of interaction, but it’d be nice if properties could be used to pass info both ways by basically just being regular variables that are exposed outside of the component.

Or maybe there is a way to set properties and I’m just really confused! In which case, help?

Hello @john_shelbyhtmq
You can get the value from a custom component using an event with a parameter.
Here is an example custom component using it: Drop-down Custom Component - Tutorials and DIY Guides - Community (thunkable.com)

Yea, I see that. So maybe this is more of a feature suggestion. I just don’t see why an event is the only way to extract variables.

Take your dropdown example:
Sometimes I might want to perform an action when the user changes the dropdown selection. An event is great for that.

But sometimes I might want to use the value selected, but I want to do it when the user performs an action on a different component (like hitting a “submit” button). It seems like the way I’d have to do this is to make an app variable that mirrors a variable already in existence inside the custom component. Using your dropdown as an example, here’s how I need to code when I want to use the selection from a separate event:
2024-04-22 11_53_14-Window

When I would think it should be possible to do this (if there was an internally editable “selection” property):
2024-04-22 11_54_48-Window

Perhaps there are technological reasons why this isn’t possible, but it seems like it makes sense?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.