Unable to persist the state in Forge Macro Config

Recently i’m implementing a dynamic form in macro config in Confluence Forge app and encountered a weird behaviour in macro config.

The columns select field options are retrieved via resolver function to fetch all the available property columns based on the Type field. The initial state of the columns is empty array (), this is why you would see No options at first.

After the resolver invocation has been executed in useEffect, the Columns select field has been filled up with the result from resolver.

However, when i try to select the next column, the macro config somehow reset the state to init state and the Columns select field became ‘No options’ again

Therefore, i would need to go through the fetching process again to fetch the available properties.

I would like to know is it an expected behaviour for macro config in forge? Seems like it impact the user experience where the user has to wait for the fetch for every option selection.

1 Like

What do you have as the dependencies for the useEffect hook? Every time you select an option, you change the config, which rerenders the component. You might be able to keep it with the right dependencies or useMemo or something similar.

2 Likes