Home App Docs Blog Github

Trigger function coming from react context

I’m trying to resolve my task:
Need to show popup which implemented inside my react app by button made within builder.
So I’m passing setState function (with popup visibility state) inside custom action, but it doesn’t trigger anything. This function declared in context from parent component.
Is it impossible to achieve that behavior?
Thank you in advance!

Hi @Jediinspace , that’s definitely possible, Builder can act as an extension to your codebase, and it can have access to methods from your codebase using the context prop

const [ popupOpen, setPopupOpen] = useState(false);
<BuilderComponent model="..." context={{ openPopup: () => { setPopupOpen(true)}}

And then in any of the action handlers in the content you can simply call that method:


Yes, thank you, I just adjusted my question. I’ve tried to do it with local useState hook and it works fine (I used the data prop and state in builder accordingly), but what if this function came from parent component? Does builder understand full execution context?