首页 > 解决方案 > 谷歌地方自动完成根本没有设置状态,也没有在控制台上显示它

问题描述

当我在另一个空白屏幕上尝试它时它可以工作但它不能在这个屏幕上工作?

但我必须在这个屏幕上

我在设置状态后尝试了条件渲染,但它不起作用



    const renderAutocomplete = () => {
      return (
        <View
          style={{
            flex: 1,
          }}
        >
          <GooglePlacesAutocomplete
            placeholder="Search..."
            onPress={(data, details = null) => {
              // 'details' is provided when fetchDetails = true
              setLocationToSet(data.description);
              console.warn(data.description);
            }}
            query={{
              key: `AIzaSyAP6ZeQjc`,
              language: "uz",
            }}
            styles={{
              textInput: {
                marginVertical: SIZES.mr,
                borderColor: COLORS.main,
                backgroundColor: COLORS.bg2,
                borderRadius: SIZES.br,
                ...FONTS.normal,
                ...FONTS.small,
              },
            }}
            renderRow={(item) => <AutocompleteRow item={item} />}
          />
        </View>
      );
    };

标签: reactjsreact-nativereact-native-androidreact-stategoogleplacesautocomplete

解决方案


推荐阅读