fix crash when canceling alert association #547
Merged
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.
Asana task: bug: UI crash when canceling out of alert linking on PA message form
This fixes an issue where starting an alert linkage and then canceling would crash the UI. The underlying issue was that the sub-form was directly updating some state on the main form, and so canceling would leave things in an inconsistent state. The fix isolates the sub-form with its own state, which is only applied to the main form when the "Apply" button is pressed.
This also demonstrates an approach to prop handling that I think is generally useful: Rather than passing setters down to sub-components and requiring them to update things directly, it's sometimes nicer to think about passing contextual callbacks (e.g.
onApply
,onSelectAlert
) and performing the actual state changes higher up in the tree. This naturally centralizes state management (which is a good thing), and also tends to reduce the amount of "wiring" required between components.