Passing callback functions while registering react components in builder

hey TimG and @dharmaraju - I was just working on integrating this in our NextJS codebase, maybe I can share how we are utilizing functions and React context.

<BuilderComponent
   model={Builder.previewingModel || 'builder-page'}
   context={{
       callbackFn,
   }} />

Then, in your custom component, you can access these via the builderState prop that is passed.

function CustomComponent(props) {
  const onClick = () => {
    props.builderState.context.callbackFn();
  }
  return (
     <button onClick={onClick}>custom button</button>
  )
}


1 Like