React Native Community Picker 不显示任何内容且打不开

React Native Community Picker Not showing anything and does not open

我正在使用 React Native 社区选择器。我在选择器中看不到任何东西,也无法打开它。

const Item = Picker.Item as any;
    
    function ActivityPicker() {
        const [value, setValue] = React.useState('key1');
        return (
          <View>
            <Picker
              testID="basic-picker"
              selectedValue={value}
              onValueChange={(v) => setValue(v)}>
              <Item label="hello" value="key0" />
              <Item label="world" value="key1" />
            </Picker>
          </View>
        );
    }

也看到这种错误

 Argument of type 'ReactText' is not assignable to parameter of type 'SetStateAction<string>'.
  Type 'number' is not assignable to type 'SetStateAction<string>

我建议让选择器显示的第一件事是定义一些维度:

       <Picker
          style={{height: 50, width: 100}} // <-----

          testID="basic-picker"
          selectedValue={value}
          onValueChange={(v) => setValue(v)}>
          <Item label="hello" value="key0" />
          <Item label="world" value="key1" />
        </Picker>