You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PollItem.tsx 920B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React from 'react';
  2. import { useSelector } from 'react-redux';
  3. import { shouldShowResults } from '../../functions';
  4. import PollAnswer from './PollAnswer';
  5. import PollResults from './PollResults';
  6. interface IProps {
  7. /**
  8. * Id of the poll.
  9. */
  10. pollId: string;
  11. /**
  12. * Create mode control.
  13. */
  14. setCreateMode: (mode: boolean) => void;
  15. }
  16. const PollItem = React.forwardRef<HTMLDivElement, IProps>(({ pollId, setCreateMode }: IProps, ref) => {
  17. const showResults = useSelector(shouldShowResults(pollId));
  18. return (
  19. <div ref = { ref }>
  20. { showResults
  21. ? <PollResults
  22. key = { pollId }
  23. pollId = { pollId } />
  24. : <PollAnswer
  25. pollId = { pollId }
  26. setCreateMode = { setCreateMode } />
  27. }
  28. </div>
  29. );
  30. });
  31. export default PollItem;