Setup
Installation
Use this setup for components in packages/mobile.
- 1
Install React Native testing dependencies
npm install -D jest @testing-library/react-native @types/jest react-test-renderer
- 2
Use React Native Babel preset in Jest transform
jest.config.jstransform: { "^.+\\.(js|jsx|ts|tsx)$": [ "babel-jest", { presets: ["module:@react-native/babel-preset"] } ] } - 3
Add shared mobile theme hook
packages/mobile/use-mobile-theme.tsimport { useColorScheme } from "react-native"; export type MobileTheme = "light" | "dark"; export function useMobileTheme(): MobileTheme { return useColorScheme() === "dark" ? "dark" : "light"; } - 4
Style components with StyleSheet
packages/mobile/example/example.tsximport { StyleSheet, View } from "react-native"; import { useMobileTheme } from "@squishui/mobile/use-mobile-theme"; const styles = StyleSheet.create({ card: { borderRadius: 8, padding: 16 }, });