Select to view content in your preferred language

Maintain state of the configuration controls in experience builder custom widget

107
1
Jump to solution
3 weeks ago
JAYAKUMARKUMAR
Emerging Contributor

Hi,

 

I am in process of developing one custom experience builder where it will have four user parameter for that I am using dropdowns. Functionality is working fine, but when user click the button F5 or refresh the page I am not able to see the parameter set by the user , the controls are resetted. 

Please let me how to maintain the control state.

0 Kudos
1 Solution

Accepted Solutions
SumitMishra_016
Frequent Contributor

Hi,

Please use "props" property to hold the values and in "Useeffect" to populate the values back to dropdown even when user refresh the page.

 useEffect(() => {
    selectedLayerIdRef.current = props.config.selectedLayerId;
    selectedFieldRef.current = props.config.selectedField;
    acquisitionDateFieldRef.current = props.config.selectedDateField;
    cameraHeadingFieldRef.current = props.config.selectedCameraHeadingField;
    showArrowRef.current = props.config.showArrow;
    showCompassRef.current = props.config.showCompass ?? false;
  }, [props.config.selectedLayerId, props.config.selectedField, props.config.selectedDateField, props.config.selectedCameraHeadingField, props.config.showArrow, props.config.showCompass]);

 

View solution in original post

1 Reply
SumitMishra_016
Frequent Contributor

Hi,

Please use "props" property to hold the values and in "Useeffect" to populate the values back to dropdown even when user refresh the page.

 useEffect(() => {
    selectedLayerIdRef.current = props.config.selectedLayerId;
    selectedFieldRef.current = props.config.selectedField;
    acquisitionDateFieldRef.current = props.config.selectedDateField;
    cameraHeadingFieldRef.current = props.config.selectedCameraHeadingField;
    showArrowRef.current = props.config.showArrow;
    showCompassRef.current = props.config.showCompass ?? false;
  }, [props.config.selectedLayerId, props.config.selectedField, props.config.selectedDateField, props.config.selectedCameraHeadingField, props.config.showArrow, props.config.showCompass]);