make it use the right placeId and canDrive when loading again

This commit is contained in:
Michael Fatemi 2021-07-25 18:06:00 -04:00
parent 785934b863
commit f443921761

View File

@ -1,4 +1,4 @@
import { useCallback, useRef } from 'react';
import { useCallback, useEffect, useRef } from 'react';
import { green, lightgrey } from '../../lib/colors';
import getPlaceDetails from '../../lib/getPlaceDetails';
import { addOrUpdateEventSignup, removeEventSignup } from '../api';
@ -15,6 +15,15 @@ export default function EventInterestForm() {
const placeIdRef = useRef<string | null>(null);
const canDriveRef = useRef(false);
{
const signup = event.signups[me.id];
useEffect(() => {
placeIdRef.current = signup?.placeId ?? null;
canDriveRef.current = signup?.canDrive ?? false;
}, [signup?.canDrive, signup?.placeId]);
}
const updateSignup = useCallback(async () => {
const placeId = placeIdRef.current;
const canDrive = canDriveRef.current;