Add a containing div element to the "still waiting" component chunks
authorCarl Worth <cworth@cworth.org>
Sun, 28 Jun 2020 16:08:06 +0000 (09:08 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 28 Jun 2020 16:08:06 +0000 (09:08 -0700)
And drop the use of a list.

The list was annoying because it was triggering the React warning:

Each child in a list should have a unique "key" prop

And in this case, it seemed really silly to have to name/distinguish
the <p> element from the following <ul> element.

And this new <div> does give us a logical place to treat this chunk of
the document as a single element if needed, so this is the logically
correct thing to do.

empathy/empathy.jsx

index e887b1b8b9b1af33ddc76aa751613f66a2253205..163b977cbb8c474560a4dfa9cf24c1a03926e56b 100644 (file)
@@ -572,26 +572,28 @@ class Ambiguities extends React.PureComponent {
     let still_waiting = null;
     const judging_players = Object.keys(this.props.players_judging);
     if (judging_players.length) {
-      still_waiting = [
-        <p>
-          Still waiting for the following player
-          {judging_players.length > 1 ? 's' : '' }
-          :
-        </p>,
-        <ul>
-          {judging_players.map(player => {
-            return (
-              <li
-                key={player}
-              >
-                {player}
-                {this.props.players_judging[player] ?
-                 <span className="typing"/> : null }
-              </li>
-            );
-          })}
-        </ul>
-      ];
+      still_waiting = (
+        <div>
+          <p>
+            Still waiting for the following player
+            {judging_players.length > 1 ? 's' : '' }
+            :
+          </p>
+          <ul>
+            {judging_players.map(player => {
+              return (
+                <li
+                  key={player}
+                >
+                  {player}
+                  {this.props.players_judging[player] ?
+                   <span className="typing"/> : null }
+                </li>
+              );
+            })}
+          </ul>
+        </div>
+      );
     }
 
     if (this.props.players_judged.has(this.props.player.name)) {
@@ -745,26 +747,28 @@ class ActivePrompt extends React.PureComponent {
     let still_waiting = null;
     const answering_players = Object.keys(this.props.players_answering);;
     if (answering_players.length) {
-      still_waiting = [
-        <p>
-          Still waiting for the following player
-          {answering_players.length > 1 ? 's' : ''}
-          :
-        </p>,
-        <ul>
-           {answering_players.map(player => {
-             return (
-               <li
-                 key={player}
-               >
-                 {player}
-                 {this.props.players_answering[player] ?
-                  <span className="typing"/> : null }
-               </li>
-             );
-           })}
-        </ul>
-      ];
+      still_waiting = (
+        <div>
+          <p>
+            Still waiting for the following player
+            {answering_players.length > 1 ? 's' : ''}
+            :
+          </p>
+          <ul>
+            {answering_players.map(player => {
+              return (
+                <li
+                  key={player}
+                >
+                  {player}
+                  {this.props.players_answering[player] ?
+                   <span className="typing"/> : null }
+                </li>
+              );
+            })}
+          </ul>
+        </div>
+      );
     }
 
     if (this.props.players_answered.has(this.props.player.name)) {