Skip to content

Commit

Permalink
set radio default on mounted (#416)
Browse files Browse the repository at this point in the history
Co-authored-by: Alyssa Wang <[email protected]>
  • Loading branch information
AlyssaWang and AlyssaWang authored Dec 9, 2023
1 parent 0181b6d commit 0c5c15e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/src/components/InputsModal/InputRadioGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react';
import React, { FC, useEffect } from 'react';
import {
FormControl,
FormControlLabel,
Expand Down Expand Up @@ -34,6 +34,12 @@ const InputRadioGroup: FC<InputRadioGroupProps> = ({
inputsMap.get(requirement.name) || requirement.default || firstValue
);

// Set default on mounted
useEffect(() => {
inputsMap.set(requirement.name, value);
setInputsMap(new Map(inputsMap));
}, []);

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const value = event.target.value;
setValue(value);
Expand Down

0 comments on commit 0c5c15e

Please sign in to comment.