Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to get the data to update using UseState?

$
0
0

I having been trying to update the data using UseState with Typescript. The data is never updated what so ever. I am not sure what is it that I am missing. I just want to make sure that the information from local mock data that accepts those 5 properties and be send or updated to the store data. But whenever the button is pressed I am still get the same information that's already there and the mock data was never imported in. Help me if there's something I am missing or something I may need to change. Thank you, and let me know if you need any more informations.

import verification from '../mock-api/sample/TripVerificationSample.json';interface VerificationTripProps {  isVisible: boolean;  style?: {};  onModalBack: () => void;  onPress: () => void;  data?: Reservation[];}const TripVerificationModal: React.FC<VerificationTripProps> = ({  isVisible = false,  onModalBack,  onPress,  data,}) => {  console.log('before data is pushed '+ JSON.stringify(data));  const [updateData, setUpdateData] = useState<Reservation[]>([]);  const LoadConfirmInfo = () => {    //set old array to add new array    setUpdateData(previous => [    ...previous,    {      confirmNumber: verification.confirmNumber,      startDate: new Date(verification.startDate),      endDate: new Date(verification.endDate),      hotel: verification.hotel,      status: ReservationStatusType.Upcoming,    },    ]);    console.log('checking if info is pushed '+ JSON.stringify(updateData));  };  return (<View><BackBaseModal        isVisible={isVisible}        onModalBack={onModalBack}        modalText={tripVerification.headerText}        subText={tripVerification.subText}        buttonText={tripVerification.confirmBtn}        onPress={() => {          onPress();          LoadConfirmInfo();        }}></View>

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>