mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2025-12-23 22:18:36 -05:00
Call navigate directly in onPress handler (#3124)
And not over setting a state and navigating based on state on modal close.
This commit is contained in:
@@ -2,7 +2,7 @@ import { useNavigation } from "@react-navigation/native";
|
||||
import type { ApiTaxon } from "api/types";
|
||||
import ExploreTaxonSearch from "components/Explore/SearchScreens/ExploreTaxonSearch";
|
||||
import Modal from "components/SharedComponents/Modal";
|
||||
import React, { useState } from "react";
|
||||
import React from "react";
|
||||
import type { RealmTaxon } from "realmModels/types";
|
||||
|
||||
type Props = {
|
||||
@@ -21,26 +21,18 @@ const ExploreTaxonSearchModal = ( {
|
||||
updateTaxon
|
||||
}: Props ) => {
|
||||
const navigation = useNavigation( );
|
||||
const [detailTaxonId, setDetailTaxonId] = useState<number | undefined | null>( null );
|
||||
|
||||
return (
|
||||
<Modal
|
||||
showModal={showModal}
|
||||
fullScreen
|
||||
closeModal={closeModal}
|
||||
disableSwipeDirection
|
||||
onModalHide={( ) => {
|
||||
if ( detailTaxonId ) {
|
||||
navigation.push( "TaxonDetails", { id: detailTaxonId } );
|
||||
}
|
||||
setDetailTaxonId( null );
|
||||
}}
|
||||
modal={(
|
||||
<ExploreTaxonSearch
|
||||
closeModal={closeModal}
|
||||
hideInfoButton={hideInfoButton}
|
||||
onPressInfo={( taxon: RealmTaxon | ApiTaxon ) => {
|
||||
setDetailTaxonId( taxon.id );
|
||||
navigation.push( "TaxonDetails", { id: taxon.id } );
|
||||
closeModal();
|
||||
if ( onPressInfo ) {
|
||||
onPressInfo( );
|
||||
|
||||
Reference in New Issue
Block a user