Skip to content

Commit

Permalink
Refactor useEffectfulState to cater reset input UI rerendering (#1009)
Browse files Browse the repository at this point in the history
* Refactor useEffectfulState to cater reset input UI rerendering

* Add changeset

* Update changeset
  • Loading branch information
jeffchang1117 authored Sep 22, 2023
1 parent 32f01f9 commit b2e87be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/slimy-guests-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'wingman-fe': patch
---

SalaryDetails: Update state fields on empty strings
3 changes: 2 additions & 1 deletion fe/lib/components/SalaryDetails/SalaryDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ export interface SalaryDetailsProps {
function useEffectfulState<T>(initialState: T) {
const [state, setState] = useState(initialState);

// Make sure we rerender the input UI when the state value is reset
useEffect(() => {
if (initialState) {
if (initialState || initialState === '') {
setState(initialState);
}
}, [initialState]);
Expand Down

0 comments on commit b2e87be

Please sign in to comment.