Skip to Main Content Ideas
Created by Jason Clark
Created on May 10, 2023

Make builderState updateable by custom React code

In working with custom React components that are registered with Builder, it could be very useful to be able to update builderState from the custom component.

An example: I have an image gallery component I created and I'd like to be able to directly update builderState so that it can be aware of what "slide" the gallery is currently displaying (useful for hiding/showing content overlaying the gallery or for triggering other actions on the page).

My thought is that it could work somewhat like a regular reducer function and return an updated instance of state without mutating the base state.

const updatedState = { ...builderState, currentSlideIndex, ...otherStateToTrack };

Given the fact that Angular observables can be used with Builder to handle a two-way binding, and the fact that React isn't a two-way data-binding framework, it means we need a hook to be able to update the builderState for most usefulness.

  • Attach files