How to use the @react-navigation/native.useFocusEffect function in @react-navigation/native

To help you get started, we’ve selected a few @react-navigation/native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github berty / berty / js / packages / components / chat / MultiMember.tsx View on Github external
const [{ background, flex }] = useStyles()
	const { dispatch } = useNavigation()
	useReadEffect(params.convId, 1000)
	const conv = useConversation(params?.convId)
	const { t } = useTranslation()
	const ctx = useMsgrContext()
	const insets = useSafeAreaInsets()

	const lastInte = useLastConvInteraction(params?.convId || '')
	const lastUpdate = conv?.lastUpdate || lastInte?.sentDate || conv?.createdDate || null
	const [stickyDate, setStickyDate] = useState(lastUpdate || null)
	const [showStickyDate, setShowStickyDate] = useState(false)

	const [isSwipe, setSwipe] = useState(true)

	useFocusEffect(
		React.useCallback(() => {
			AndroidKeyboardAdjust?.setAdjustResize()
			return () => AndroidKeyboardAdjust?.setAdjustPan()
		}, []),
	)

	return (
		
			{({ activeEmojiKeyboardCid, setActiveEmojiKeyboardCid, setActivePopoverCid }) => {
				const onRemoveEmojiBoard = () => {
					setActivePopoverCid(activeEmojiKeyboardCid)
					setActiveEmojiKeyboardCid(null)
				}
				return (
github react-navigation / navigation-ex / example / src / Screens / NativeStack.tsx View on Github external
export default function NativeStackScreen({ navigation }: Props) {
  navigation.setOptions({
    headerShown: false,
  });

  useFocusEffect(
    React.useCallback(() => {
      const drawer = navigation.dangerouslyGetParent() as DrawerNavigationProp<
        ParamListBase
      >;

      navigation.setOptions({ gestureEnabled: false });
      drawer.setOptions({ gestureEnabled: false });

      return () => {
        navigation.setOptions({ gestureEnabled: true });
        drawer.setOptions({ gestureEnabled: true });
      };
    }, [navigation])
  );

  return (
github berty / berty / js / packages / components / chat / OneToOne.tsx View on Github external
const { t } = useTranslation()
	const conv = useConversation(params?.convId)
	const contact = useContact(conv?.contactPublicKey)
	const ctx = useMsgrContext()

	const isIncoming = contact?.state === beapi.messenger.Contact.State.IncomingRequest
	const isFooterDisable = isIncoming
	const placeholder = isFooterDisable
		? t('chat.one-to-one.incoming-input-placeholder')
		: t('chat.one-to-one.input-placeholder')

	const [stickyDate, setStickyDate] = useState(conv?.lastUpdate || null)
	const [showStickyDate, setShowStickyDate] = useState(false)
	const [isSwipe, setSwipe] = useState(true)

	useFocusEffect(
		React.useCallback(() => {
			AndroidKeyboardAdjust?.setAdjustResize()
			return () => AndroidKeyboardAdjust?.setAdjustPan()
		}, []),
	)

	return (
		
			{({ activeEmojiKeyboardCid, setActiveEmojiKeyboardCid, setActivePopoverCid }) => {
				const onRemoveEmojiBoard = () => {
					setActivePopoverCid(activeEmojiKeyboardCid)
					setActiveEmojiKeyboardCid(null)
				}
				return (