is there any way to dynamically create block components. Suppose there is a TextControl component in a block and I want users to click on add new field button and it creates new TextControl block automatically?
2 Answers
0
votes
Yes, This testimonial block will add new field upon clicking "+" button. More better explanation of how things are working under the hood, see this blog post
0
votes
This should be fairly simple. The key is storing text control values in a single attribute via an array, rather separate attributes.
Then, when a new text control is added just insert this into the array. To display controls just loop through the array.
I've used this method numerous times in WordPress plugins but not yet in a block but it shouldn't be any different for blocks.