Resources

Ɨ

Visual CMS

Drag-and-drop visual editor and headless CMS for any tech stack

Theme Studio for Shopify

Build and optimize your Shopify-hosted storefront, no coding required

Resources

Blog

Get StartedLogin

ā˜°

Home

Forum

Blog

Github

Login

Signup

Made in Builder

Triggering Customs Actions in Builder with React

Sometimes you want buttons in your builder content to trigger code in your React app. Follow along below to learn how you can do this.

Passing down the function

Using the data attribute, we can pass down any key/value pair we like to be used in our Builder content

Triggering the function in builder

Let's assign our function to run on click of a button. Using the data tab, create a new "click" event. In the event handler, there is a state variable that holds all of the data you passed. Simply call state.myFunction() and you are done!

Was this article helpful?