Skip to content

Commit

Permalink
only load participants when clicking show participants
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikskog committed Sep 18, 2023
1 parent 5b5b8cd commit 9bc9494
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ export const ParticipantsButton: FC<IProps> = ({ eventId, eventTitle }) => {
const attendees = useSelector(selectPublicAttendeesForEventId(eventId));
const [showModal, setShowModal] = useState(false);

const toggleModal = () => setShowModal(!showModal);

useEffect(() => {
dispatch(fetchPublicAttendeesByEventId(eventId));
}, [eventId]);
const toggleModal = () => {
if (!showModal) {
if (attendees.length === 0) {
dispatch(fetchPublicAttendeesByEventId(eventId));
}
setShowModal(true);
} else {
setShowModal(false);
}
};

// disables background scrolling when the modal is open
useEffect(() => {
Expand Down

1 comment on commit 9bc9494

@vercel
Copy link

@vercel vercel bot commented on 9bc9494 Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.