Dynamic dropdown based on react hook

54 views
Skip to first unread message

ArM

unread,
Sep 23, 2023, 12:31:45 PM9/23/23
to Blockly
Hello. Is there any way to achieve a "reactive" dropdown based on a react hook? I want to change the dropdown items, on all my blocks that uses the target dropdown, when a variable changes.

Mark Friedman

unread,
Sep 23, 2023, 6:22:34 PM9/23/23
to blo...@googlegroups.com
Note that the FieldDropdown constructor can take a function as an argument, rather than an array of values for the dropdown.  That function dynamically generates the dropdown values.  So to do what you are talking about just have that function use data/state that is set by the React hook.

Hope this helps.

-Mark


On Sat, Sep 23, 2023 at 9:32 AM ArM <rantaa...@gmail.com> wrote:
Hello. Is there any way to achieve a "reactive" dropdown based on a react hook? I want to change the dropdown items, on all my blocks that uses the target dropdown, when a variable changes.

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/1b475d88-5ea4-4800-88c8-4da8c355c813n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages