I am currently in the process of developing a compact puzzle app that resembles a crossword using Expo, React Native, and Typescript.
Below is a concise version of the PuzzleMain component:
const PuzzleMain: React.FC<PuzzleMainProps> = ({ navigation }) => {
let puzzle: AcrosticPuzzleData = parseAcrosticPuzzle(PUZZLE_TEXT);
const grid = <PuzzleGrid puzzle={puzzle} />;
const clueView = <PuzzleCluesView puzzle={puzzle} />;
const [index, setIndex] = React.useState(0);
return <View style={styles.container}>
{index == 0 ? grid : clueView}
<View style={styles.keyboardContainer}>
<Button onPress={() => setIndex(index == 1 ? 0 : 1)} title={"See " + routes[index == 0 ? "Grid" : "Clues"].key} />
<Keyboard />
</View>
</View>;
}
In summary, there are components for the "grid" and "clues," and a button allows users to switch between them.
When tapping this button, it takes approximately 3 seconds for the change to occur on my Pixel 5 test device. This delay does not occur when testing on web using Expo, so it may be specific to Android devices?
Here are some troubleshooting steps I have taken:
- Memoizing the
PuzzleGrid
andPuzzleCluesView
components (
. However, this did not significantly improve performance. There were no console logs from a custom puzzle comparator used in the memo function, indicating re-rendering may not be the issue.const PuzzleGrid: React.FC<Props> = memo(({ puzzle }) ...
- Utilizing TabView to swipe between components instead - this approach yielded better results. Nonetheless, I prefer having both options available, and adding the button to the TabView implementation resulted in similar delays.
- Running
npx expo start --no-dev
and building an apk for installation - while this method showed faster loading times, there was still a noticeable delay of about a second or two, which is considered too slow.