Conditionally rendering a block based on another (unrelated) block’s attribute. What’s my best choice here?

To clarify here is what I want to achieve:
– The user can only input either Data1 or Data2. To do this, I would provide a different input for each data and conditionally render these input fields based on a form with radio buttons.

Now I could easily do this by grouping the two different inputs with the radio button(s) form and then conditionally rendering the input that is selected by the user. However, my problem is that Data2 is not just a single input. Data2 lets the user input limited blocks while Data1 is only a single input field.

Another way to rephrase my problem/question is how would I restrict the user from adding blocks when they choose Data1?

I could have used an InnerBlock to restrict addition of other blocks but I don’t want to restrict the user when they choose Data2. The problem is that InnerBlock cannot be re-rendered as far as I know so I cannot conditionally assign a template or allowBlocks to it.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Your Advertisement Here