fix: modal-theme-update-on-state-change #1676
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug fix for the issue from widget v0.2.0 and up where the widgets state wont update when the config changes on theme change or env change.
I believe the migration to vite caused the bug as ever since the migration, the trick of passing a key to the react widget as the strinified config stopped working and caused the widget to not mount on change in the config
solution is just to manage some the worm-hole apps config as state variables instad of just inline exports such as most of the config is.
the widgets config really would only change either when the theme is changed or the env is changed. all other params either depend on these, or woill likely not change. so for now i extended the theme config and the env/netowrk config items to a context at the top of the app
updating the widget externally seems to never work by conventional means in terms of trying to cause internal rerenders when the config changes. im not sure why exactly this is spent a while trying many ways. i think maybe its because the config is initialised in-line and non stateful and el the selector that gets the wormhole-connect is too. so i wonder does the config just nevr change because the worm-hole div selector never changes. it initialized once in current implementation and never updates as config changes.
so thinking this i add the config initialuzation and this selector init to a useeffect and create a custom event trigger to update the config when triggered. every is fixed now the widget now updates on config change