Skip to content

Commit 9807b45

Browse files
committed
crude attempt at exposing a memo-buster
1 parent e73c057 commit 9807b45

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/create.ts

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export function create(customConfig: TwConfig, platform: Platform): TailwindFn {
199199
tailwindFn.setPixelDensity = (newPixelDensity: 1 | 2) => {
200200
device.pixelDensity = newPixelDensity;
201201
cacheGroup = deriveCacheGroup();
202+
return cacheGroup;
202203
};
203204

204205
tailwindFn.setColorScheme = (newColorScheme: RnColorScheme) => {

src/hooks.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from 'react';
22
import { useColorScheme, useWindowDimensions, Appearance } from 'react-native';
3-
import { TailwindFn, RnColorScheme } from './types';
3+
import type { TailwindFn, RnColorScheme } from './types';
44

55
type Options = {
66
withDeviceColorScheme: boolean;
@@ -9,15 +9,16 @@ type Options = {
99
export function useDeviceContext(
1010
tw: TailwindFn,
1111
opts: Options = { withDeviceColorScheme: true },
12-
): void {
12+
): string {
1313
const window = useWindowDimensions();
1414
tw.setWindowDimensions(window);
1515
tw.setFontScale(window.fontScale);
16-
tw.setPixelDensity(window.scale === 1 ? 1 : 2);
16+
const memoBuster = tw.setPixelDensity(window.scale === 1 ? 1 : 2);
1717
const colorScheme = useColorScheme();
1818
if (opts.withDeviceColorScheme) {
1919
tw.setColorScheme(colorScheme);
2020
}
21+
return String(memoBuster);
2122
}
2223

2324
export function useAppColorScheme(

0 commit comments

Comments
 (0)