Skip to content

Commit 039afb8

Browse files
committed
first attempt to fix with a hook-based memo-buster
1 parent 2c208a7 commit 039afb8

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

App.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,23 @@ import Layout from './components/Layout';
1010
const Stack = createNativeStackNavigator();
1111

1212
export default function App() {
13-
useDeviceContext(tw, { withDeviceColorScheme: false });
13+
// 👇 -- i'm proposing that `useDeviceContext` could return a string for memoization busting
14+
const memoBuster = useDeviceContext(tw, { withDeviceColorScheme: false });
15+
1416
const [, toggleColorScheme] = useAppColorScheme(tw);
1517

1618
return (
1719
<Layout>
1820
<TouchableOpacity onPress={toggleColorScheme}>
1921
<Text
20-
style={tw`bg-gray-200 dark:bg-gray-900 text-black dark:text-white
21-
capitalize p-2 mt-24 text-center`}
22+
style={tw`bg-gray-200 dark:bg-gray-900 text-black dark:text-white capitalize p-2 mt-24 text-center`}
2223
>
2324
toggle theme
2425
</Text>
2526
</TouchableOpacity>
2627
<NavigationContainer>
2728
<Stack.Navigator
29+
key={memoBuster} // 👋 <-- busting it here seems(?) to work
2830
screenOptions={{
2931
headerRight: () => (
3032
<TouchableOpacity onPress={toggleColorScheme}>

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"react-native-safe-area-context": "4.6.3",
2020
"react-native-screens": "~3.22.0",
2121
"react-native-web": "^0.19.9",
22-
"twrnc": "^3.6.4"
22+
"twrnc": "^3.7.0-beta"
2323
},
2424
"devDependencies": {
2525
"@babel/core": "^7.20.0"

0 commit comments

Comments
 (0)