Conversation
…rrors for first couple steps of IPP flow
…ley/lg-6874-retain-doc-capture-errors
aduth
left a comment
There was a problem hiding this comment.
This is a clever solution, nice!
| const [previousErrors, setPreviousErrors] = useState<PreviousErrorsLookup>({}); | ||
|
|
||
| useEffect(() => { | ||
| const prevErrs = previousErrors[stepName || steps[0]?.name]; |
There was a problem hiding this comment.
In at least one other place in the file we reference the step name by step?.name, since step would be the result of validating stepName in the set of steps. We could move this useEffect a bit down (or conversely, move the step assignment a bit up) to use it.
There was a problem hiding this comment.
Still works as intended, so the useEffect has been moved.
| const [previousErrors, setPreviousErrors] = useState<PreviousErrorsLookup>({}); | ||
|
|
||
| useEffect(() => { | ||
| const prevErrs = previousErrors[stepName || steps[0]?.name]; |
There was a problem hiding this comment.
Minor: It could be useful to disambiguate the two different "previous errors" here by incorporating "step" into the name, e.g.
| const prevErrs = previousErrors[stepName || steps[0]?.name]; | |
| const previousStepErrors = previousErrors[stepName || steps[0]?.name]; |
There was a problem hiding this comment.
I decided to rename the state value instead of the one in useEffect. Given that the const in useEffect is used only on the following line and nowhere else, I don't think a rename of that const is particularly helpful.
… per peer review feedback
GIF Demo
Testing Steps