首页 > 解决方案 > SearchParams 的 If Else 语句 [React Native]

问题描述

我是 React Native 的新手,我正在为 React Native 使用 typescript。目前,我很难为搜索功能做 if else 语句。下面是我的搜索功能 if else 语句的代码。

{searchParams !== "" (
  <View>
    <Text>Sorry, error occur</Text>
  </View>
  ) : (
  <View>
    <Text>Success!</Text>
  </View>
)}

标签: typescriptreact-nativesearchbar

解决方案


{searchParams !== "" ? (
  <View>
    <Text>Sorry, error occur</Text>
  </View>
  ) : (
  <View>
    <Text>Success!</Text>
  </View>
)}

你错过了一个问号:https ://stackoverflow.com/a/10270383/11760094


推荐阅读