import React, { useState } from 'react'; import TinderCard from 'react-tinder-card'; import './Tinder.css'; const Tinder = (props) => { const route = props.getValue; const cardInfo = props.cardInfo; const [lastDirection, setLastDirection] = useState(); const [cardId, setCardId] = useState([]); const [allIds, setAllIds] = useState([]); const swiped = (direction, id) => { setLastDirection(direction); allIds.push(id); console.log(allIds.length); if (direction === 'right' || direction === 'up') { cardId.push(id); }; }; const handleDislike = (id) => { console.log('left'); swiped('left', id); }; const handleLike = (id) => { console.log('right'); swiped('right', id); }; return (
{cardInfo.map((card) => ( { swiped(dir, card.id); var unique = [...new Set(cardId)] var uniqueIds = [...new Set(allIds)]; if(uniqueIds.length === cardInfo.length) { route('/main'); console.log(unique); } }} >

{card.question}

))}
); } export default Tinder;