Skip to content

Commit 6552ffd

Browse files
authored
fix: fix up code, add type export to fix strict JS compilers (#63)
1 parent adb8658 commit 6552ffd

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/components/Toast.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,7 @@ export const Toast: FC<Props> = ({
7575
}) => {
7676
const insets = useSafeAreaInsets();
7777
const { width, height } = useWindowDimensions();
78-
79-
useVisibilityChange(
80-
() => {
81-
onToastShow?.(toast);
82-
},
83-
() => {
84-
onToastHide?.(toast);
85-
},
86-
toast.visible
87-
);
88-
8978
const isSystemDarkMode = useColorScheme() === 'dark';
90-
const isDarkMode =
91-
overrideDarkMode !== undefined ? overrideDarkMode : isSystemDarkMode;
9279

9380
const [toastHeight, setToastHeight] = useState<number>(
9481
toast?.height ? toast.height : DEFAULT_TOAST_HEIGHT
@@ -98,6 +85,9 @@ export const Toast: FC<Props> = ({
9885
toast?.width ? toast.width : width - 32 > maxWidth ? maxWidth : width - 32
9986
);
10087

88+
const isDarkMode =
89+
overrideDarkMode !== undefined ? overrideDarkMode : isSystemDarkMode;
90+
10191
const startingY = useMemo(
10292
() =>
10393
toast.position === ToastPosition.TOP
@@ -111,6 +101,7 @@ export const Toast: FC<Props> = ({
111101
const offsetY = useSharedValue(startingY);
112102

113103
const onPress = () => onToastPress?.(toast);
104+
114105
const dismiss = useCallback((id: string) => {
115106
toasting.dismiss(id);
116107
}, []);
@@ -215,6 +206,16 @@ export const Toast: FC<Props> = ({
215206
toast.animationConfig,
216207
]);
217208

209+
useVisibilityChange(
210+
() => {
211+
onToastShow?.(toast);
212+
},
213+
() => {
214+
onToastHide?.(toast);
215+
},
216+
toast.visible
217+
);
218+
218219
useEffect(() => {
219220
setToastHeight(toast?.height ? toast.height : DEFAULT_TOAST_HEIGHT);
220221
}, [toast.height]);

src/components/Toasts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export const Toasts: FunctionComponent<Props> = ({
6060
left: insets.left + (extraInsets?.left ?? 0),
6161
right: insets.right + (extraInsets?.right ?? 0),
6262
bottom: insets.bottom + (extraInsets?.bottom ?? 0) + 16,
63+
pointerEvents: 'box-none',
6364
}}
64-
pointerEvents={'box-none'}
6565
>
6666
{toasts.map((t) => (
6767
<Toast

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export { useToaster } from './core/use-toaster';
22
export { Toasts } from './components';
33
export * from './headless';
4-
export { ToastPosition, ToastAnimationType } from './core/types';
4+
export { ToastPosition, type ToastAnimationType } from './core/types';

0 commit comments

Comments
 (0)