Skip to content

Commit

Permalink
Merge pull request #242 from tchryssos/tc-defense-context-initial-update
Browse files Browse the repository at this point in the history
Recalculate defense on quick access load
  • Loading branch information
tchryssos authored Sep 16, 2024
2 parents 0842ba5 + a4cb510 commit f17c5cd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/rulebookSpecific/sotww/QuickAccess.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from '@emotion/styled';
import { trim } from 'lodash';
import { useContext } from 'react';
import { useContext, useEffect } from 'react';
import { useFormContext } from 'react-hook-form';

import { FlexBox } from '~/components/box/FlexBox';
Expand All @@ -17,7 +17,7 @@ const LongEffect = styled(Text)`

export function QuickAccess() {
const { watch } = useFormContext<SotwwCharacterData>();
const { totalDefense } = useContext(DefenseContext);
const { totalDefense, recalculateDefense } = useContext(DefenseContext);

const equippedWeapon = watch('weapons').find((w) => w.weapon_equipped);
const weaponText = equippedWeapon
Expand All @@ -30,6 +30,10 @@ export function QuickAccess() {
const conditions = watch('conditions');
const boonBane = watch('boons_and_banes');

useEffect(() => {
recalculateDefense();
}, [recalculateDefense]);

return (
<FormSection
borderColor="primary"
Expand Down

0 comments on commit f17c5cd

Please sign in to comment.