Why does this conditional return work in browser, but not on Android phone?

Viewed 24

Working on a React Native app in Expo, I am encountering a strange problem: everything is fine in browser preview, but on the phone the conditional return does not happen.


  return (
    <ScrollView>
<View>
      <QCard
        sculpture={sculpture}
        query={query}
        handleChange={handleChange}
        handleSubmit={handleSubmit}
      />
      {search === sculpture.name ? (
        <RCard sculpture={sculpture} />
      ) : (
        <View>
          <Text>{count}</Text>
        </View>
      )}
</View>
    </ScrollView>
  );
}

A log in the terminal returns the correct values, but no return is triggered.

To reproduce, do the following:

  1. clone the repository
  2. run nvm use --lts && expo start
  3. open the app on an android phone Expo app
  4. click 'next' on the first page (count 0)
  5. type in 'August' and click on 'submit' on the second page (count 1)

https://github.com/ydrea/rnthegame.git ('design' branch)

AGame.js

1 Answers

resolved it in a roundabout manner...


  //submit query to search
  const handleSubmit = () => {
    searchSet(query);
    //flip the switches
    checkSet(true);
    querySet("");
  };
  //a bit of...
  useEffect(() => {
    //...cleanup for the next one
    checkSet(false);
  }, [count]);
  //
  return (...
<View>
          {!check ? (
            <Text>{count}</Text>
          ) : (
            <View>
              <RCard sculpture={sculpture} />
            </View>
          )}
        </View>
     
Related