Browse Source

#128 Fix bug with duplicating ids

Andrei Biasprozvanny 2 years ago
parent
commit
37374e259f

+ 2 - 2
apps/petitions/petitions-app/src/components/PetitionSignatures.jsx

@@ -1,11 +1,11 @@
1 1
 import React, { Component } from 'react';
2 2
 import styled from 'styled-components';
3 3
 import PropTypes, { string } from 'prop-types';
4
+import shortid from 'shortid';
4 5
 import { chevronLeft } from 'react-icons-kit/fa/chevronLeft';
5 6
 import { chevronRight } from 'react-icons-kit/fa/chevronRight';
6 7
 import { SecondaryPageTitle, InfoHighlight } from './common/Elements';
7 8
 
8
-
9 9
 const SignaturesCard = styled.section`
10 10
     margin-top: 2rem;
11 11
     max-width: 30rem;
@@ -113,7 +113,7 @@ class PetitionSignatures extends Component {
113 113
     const currentItems = signatories.slice(indexOfFirstItem, indexOfLastItem);
114 114
 
115 115
     return currentItems.map(item =>
116
-      <TableRow key={item}><Signatory>{item}</Signatory></TableRow>);
116
+      <TableRow key={shortid.generate()}><Signatory>{item}</Signatory></TableRow>);
117 117
   }
118 118
 
119 119
   renderPageNumbers(signatories) {

+ 5 - 0
package-lock.json

@@ -144,6 +144,11 @@
144 144
       "version": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
145 145
       "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
146 146
     },
147
+    "short-uid": {
148
+      "version": "0.1.0",
149
+      "resolved": "https://registry.npmjs.org/short-uid/-/short-uid-0.1.0.tgz",
150
+      "integrity": "sha1-Bp2U0ET8SYr7Dqe7IsXmNJeUNMg="
151
+    },
147 152
     "styled-components": {
148 153
       "version": "https://registry.npmjs.org/styled-components/-/styled-components-2.1.2.tgz",
149 154
       "integrity": "sha1-u0GZeOEofF0NiPqRBrLddfZqMkw=",