Files
mattermost-mobile/app/hooks/navigation_button_pressed.tsx
Avinash Lingaloo 216b7058df Gekidou Minor Fixes (#6461)
* removed useless throw in comment

* fix ts for useNavButtonPressed

* update server db 'relationship config file'

adding missing relationship between ThreadsInTeam and Thread table.  we will have to update the pngs and the others as well but we can do that once we get a license to the DB Schema app

* Update post.ts
2022-07-08 14:26:12 +04:00

26 lines
843 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {DependencyList, EffectCallback, useEffect} from 'react';
import {Navigation} from 'react-native-navigation';
type Callback = EffectCallback | (() => Promise<void>);
const useNavButtonPressed = (navButtonId: string, componentId: string, callback: Callback, deps?: DependencyList) => {
useEffect(() => {
const unsubscribe = Navigation.events().registerComponentListener({
navigationButtonPressed: ({buttonId}: { buttonId: string }) => {
if (buttonId === navButtonId) {
callback();
}
},
}, componentId);
return () => {
unsubscribe.remove();
};
}, deps);
};
export default useNavButtonPressed;