첫 커밋
This commit is contained in:
15
src/app/lib/use-native-navigate-listener.ts
Normal file
15
src/app/lib/use-native-navigate-listener.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { bridge } from '@/bridge';
|
||||
import { PathType } from '@/shared/constants/paths';
|
||||
import { useEffect } from 'react';
|
||||
import { useNavigate } from '@/shared/lib/hooks';
|
||||
import { NativeMessage } from '@/shared/constants/native-message';
|
||||
|
||||
export const useNativeNavigateListener = () => {
|
||||
const { navigate } = useNavigate();
|
||||
useEffect(() => {
|
||||
// Subscribe to events from react native.
|
||||
return bridge.addEventListener(NativeMessage.WebViewNavigate, (message: any) => {
|
||||
navigate(message.path as PathType);
|
||||
});
|
||||
}, []);
|
||||
};
|
||||
Reference in New Issue
Block a user