我正在使用来自 reactstrap 的 CustomInput。我正在设置要选择的类型。在我的 CustomInput type="select" 中,我正在映射数组中的选项。我需要将选择中的默认值设置为正在映射的特定选项。例如。我喜欢默认为美国或德国,现在我正在映射一系列不同的国家。
这是我下面的代码
<CustomInput
type="select"
id="country"
name="country"
className="mb-3"
value={country.countryCode}
onChange={handleChange}
>
{numberCountries.map(({countryCode, name}) => (
<Fragment>
<option key={countryCode} value={countryCode}>{name}</option> <--- how can i set a one of these options to be the default value rendered on the screen?
</Fragment>
))}
</CustomInput>
这是我正在映射的对象
[
{
name: 'United States',
countryCode: 'US'
},
{
name: 'Germany',
countryCode: 'DE'
}
]