feat: add unique key prop to g
This commit is contained in:
parent
bc6c2a4a98
commit
854bd03c40
@ -1,5 +1,6 @@
|
|||||||
import { FC, useEffect, useState } from "react";
|
import { FC, useEffect, useState } from "react";
|
||||||
import { PlayerRanking } from "./types";
|
import { PlayerRanking } from "./types";
|
||||||
|
import { useSession } from "./Session";
|
||||||
|
|
||||||
interface RaceChartProps {
|
interface RaceChartProps {
|
||||||
players: PlayerRanking[];
|
players: PlayerRanking[];
|
||||||
@ -34,13 +35,13 @@ const RaceChart: FC<RaceChartProps> = ({ players, std }) => {
|
|||||||
const gap = 8;
|
const gap = 8;
|
||||||
const maxValue = Math.max(...players.map((player) => player.rank)) + 1;
|
const maxValue = Math.max(...players.map((player) => player.rank)) + 1;
|
||||||
const barHeight = (height - 2 * padding) / players.length;
|
const barHeight = (height - 2 * padding) / players.length;
|
||||||
const fontSize = Math.min(barHeight - 1.5 * gap, width / 20);
|
const fontSize = Math.min(barHeight - 1.5 * gap, width / 22);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<svg width={width} height={height}>
|
<svg width={width} height={height} id="RaceChartSVG">
|
||||||
{players.map((player, index) => (
|
{players.map((player, index) => (
|
||||||
<rect
|
<rect
|
||||||
key={index}
|
key={String(index)}
|
||||||
x={0}
|
x={0}
|
||||||
y={index * barHeight + padding}
|
y={index * barHeight + padding}
|
||||||
width={(1 - player.rank / maxValue) * width}
|
width={(1 - player.rank / maxValue) * width}
|
||||||
@ -50,7 +51,7 @@ const RaceChart: FC<RaceChartProps> = ({ players, std }) => {
|
|||||||
))}
|
))}
|
||||||
|
|
||||||
{players.map((player, index) => (
|
{players.map((player, index) => (
|
||||||
<g>
|
<g key={"group" + index}>
|
||||||
<text
|
<text
|
||||||
key={index + "_name"}
|
key={index + "_name"}
|
||||||
x={4}
|
x={4}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user