Skip to content

Commit

Permalink
deterministic hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mgwalker committed Aug 12, 2019
1 parent a46c65f commit c5ef40e
Showing 1 changed file with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,17 @@ const ContractorResourceForm = ({

const handle = {
changeDesc: useCallback(handleChange(index, 'desc'), []),
changeHourlyHours: apdFFYs.reduce(
(acc, ffy) => ({
...acc,
[ffy]: useCallback(handleHourlyChange(index, ffy, 'hours'), [apdFFYs])
}),
{}
changeHourlyHours: useCallback(
ffy => handleHourlyChange(index, ffy, 'hours'),
[index]
),
changeHourlyRate: apdFFYs.reduce(
(acc, ffy) => ({
...acc,
[ffy]: useCallback(handleHourlyChange(index, ffy, 'rate'), [apdFFYs])
}),
{}
changeHourlyRate: useCallback(
ffy => handleHourlyChange(index, ffy, 'rate'),
[index]
),
changeName: useCallback(handleChange(index, 'name'), []),
changeTotalCost: useCallback(handleChange(index, 'totalCost'), []),
changeYearCost: apdFFYs.reduce(
(acc, ffy) => ({
...acc,
[ffy]: useCallback(handleYearChange(index, ffy), [apdFFYs])
}),
{}
),
changeYearCost: useCallback(ffy => handleYearChange(index, ffy), [index]),
setUseHourlyOff: useCallback(handleUseHourly(key, false), []),
setUseHourlyOn: useCallback(handleUseHourly(key, true), [])
};
Expand Down Expand Up @@ -127,7 +115,7 @@ const ContractorResourceForm = ({
type="number"
size="medium"
value={hourly.data[ffy].hours}
onChange={handle.changeHourlyHours[ffy]}
onChange={handle.changeHourlyHours(ffy)}
/>
<DollarField
className="ds-u-margin-left--1"
Expand All @@ -136,7 +124,7 @@ const ContractorResourceForm = ({
labelClassName="ds-u-margin-top--1"
size="medium"
value={hourly.data[ffy].rate}
onChange={handle.changeHourlyRate[ffy]}
onChange={handle.changeHourlyRate(ffy)}
/>
</div>
</Fragment>
Expand Down Expand Up @@ -166,7 +154,7 @@ const ContractorResourceForm = ({
disabled={hourly.useHourly}
size="medium"
value={years[ffy]}
onChange={handle.changeYearCost[ffy]}
onChange={handle.changeYearCost(ffy)}
/>
))
)}
Expand Down

0 comments on commit c5ef40e

Please sign in to comment.