Skip to content

Commit

Permalink
Merge pull request #473 from GetStream/fix/reaction-list-fix
Browse files Browse the repository at this point in the history
Only render <SimpleReactionList /> if there are reactions
  • Loading branch information
Amin Mahboubi authored Jul 27, 2020
2 parents 84bf438 + 2a62682 commit f8a3878
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/Reactions/SimpleReactionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const SimpleReactionsList = ({
}) => {
const [tooltipReactionType, setTooltipReactionType] = useState(null);

if (!reactions || reactions.length === 0) {
return null;
}

/** @param {string | null} type */
const getUsersPerReactionType = (type) =>
reactions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ const expectEmojiToHaveBeenRendered = (id) => {
describe('SimpleReactionsList', () => {
afterEach(jest.clearAllMocks);

it('should not render anything if there are no reactions', () => {
const { container } = renderComponent({
reaction_counts: {},
});
expect(container).toBeEmptyDOMElement();
});

it('should render the total reaction count', () => {
const { getByText } = renderComponent({
reaction_counts: {
Expand Down

0 comments on commit f8a3878

Please sign in to comment.