fix: set initial value in CountryCodeSelect (#1890)

This commit is contained in:
Yaodong Yu
2023-05-24 23:27:04 +08:00
committed by GitHub
parent c57c6e37dd
commit 225e9cf70a
2 changed files with 7 additions and 4 deletions

View File

@ -17,10 +17,12 @@ import * as Setting from "../../Setting";
import React from "react";
export const CountryCodeSelect = (props) => {
const {onChange, style, disabled, value} = props;
const {onChange, style, disabled} = props;
const countryCodes = props.countryCodes ?? [];
const [value, setValue] = React.useState(countryCodes.length > 0 ? countryCodes[0] : "");
const handleOnChange = (value) => {
setValue(value);
onChange?.(value);
};