-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ [open-formulieren/open-forms#4929] Refactor the FormStart componen…
…t into own route The component is refactored with the goal of configuring it in a static route definitions file, which means it cannot take any dynamic props as input as that is not statically available. The most important props are the current submission in the session, initial data reference and callbacks for when a submission is created or session stopped (because the user logs out, for example). For the initial data reference, we can use the hook from earlier refactors to grab it directly from the query parameters. The submission and relevant callbacks are now provided by the container/wrapper Form component that manages the submission state, through context. We have to be careful here to properly memoize callbacks as there's quite a substantial risk of running into infinite re-renders locking up the browser. Hopefully in the future we can remove those footguns by using loaders and actions of the react-router library. The core onFormStart callback is hereby also moved from the Form component to the FormStart component which properly localizes the related behaviours. We only send the created submission back up to the parent state when the creation is done. Additionally, I've opted to use 'named arguments' for the anonymous flag to make the code easier to read/understand. Secondly, the browser event doesn't need to be passed to the callback, since the form submit event is already suppressed when the callback is invoked. Finally - the previous version of this code would also reset the session expiry whenever a submission is started. This was required to get rid of the session expired error message. This had become obsolete when the session expiry was moved to its own route and component, which already resets the session automatically. No expiry messages are displayed when you navigate away from the expiry notice to the start page by clicking the restart link.
- Loading branch information
1 parent
f30831a
commit 00d6ee7
Showing
6 changed files
with
106 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters