refactor: more TS code

This commit is contained in:
Tristan Yang
2022-07-29 22:59:22 +08:00
parent 6bb7af46a0
commit 33c24baecb
52 changed files with 232 additions and 273 deletions
+15 -7
View File
@@ -1,4 +1,4 @@
import { useState, useId } from "react";
import { useState, useId, FC } from "react";
import styled from "styled-components";
const StyledForm = styled.form`
@@ -61,17 +61,24 @@ const StyledForm = styled.form`
}
}
`;
type Props = {
options: string[];
values: (string | number)[];
defaultValue?: string | number;
onChange?: (param: any) => void;
value: object | number | string;
};
const VALUE_NOT_SET = {};
const VALUES_NOT_SET = {};
const VALUE_NOT_SET = "";
const VALUES_NOT_SET: string[] = [];
export default function Radio({
const Radio: FC<Props> = ({
options,
values = VALUES_NOT_SET,
value = VALUE_NOT_SET,
defaultValue = undefined,
defaultValue = "",
onChange = undefined
}) {
}) => {
const id = useId();
const [fallbackValue, setFallbackValue] = useState(defaultValue);
@@ -104,4 +111,5 @@ export default function Radio({
))}
</StyledForm>
);
}
};
export default Radio;