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.js 736B

123456789101112131415161718192021222324252627282930313233343536
  1. // @flow
  2. import React from 'react';
  3. import { useSelector } from 'react-redux';
  4. import { PollAnswer, PollResults } from '..';
  5. import { shouldShowResults } from '../../functions';
  6. type Props = {
  7. /**
  8. * Id of the poll
  9. */
  10. pollId: string,
  11. }
  12. const PollItem = React.forwardRef<Props, HTMLElement>(({ pollId }, ref) => {
  13. const showResults = useSelector(state => shouldShowResults(state, pollId));
  14. return (
  15. <div ref = { ref }>
  16. { showResults
  17. ? <PollResults
  18. key = { pollId }
  19. pollId = { pollId } />
  20. : <PollAnswer
  21. pollId = { pollId } />
  22. }
  23. </div>
  24. );
  25. });
  26. export default PollItem;