SearchParams 的 If Else 语句 [React Native]

If Else Statement for SearchParams [React Native]

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

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

你漏掉了一个问号:

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

这是 link