首页 > 解决方案 > react tbody 上的关键道具警告

问题描述

我得到一个

列表中的每个孩子都应该有一个唯一的“关键”道具。

在 tbody 线上,我不知道为什么。该组件的每个子组件都有键,从外观上看,它在 LocationListItem 组件中没有警告。我觉得我只是不明白一些事情。

    <Table striped bordered hover>
        <thead>
            <tr>
                <th>Name</th>
                <th>Address</th>
                <th>City</th>
                <th>State</th>
                <th>PostalCode</th>
                <th>Phone Number</th>
                <th>Tax Rate</th>
            </tr>
        </thead>
        <tbody key="tbody">
            {stores.map((item: any, index: number) => {
                if (item.LTPMerchantId == null) {
                    item.LTPMerchantId = "";
                }
                if (item.ChaseOrbitalMerchantId == null) {
                    item.ChaseOrbitalMerchantId = "";
                }
                if (item.CYBSMerchantId == null) {
                    item.CYBSMerchantId = "";
                }
                return (
                    <>
                        {
                            <LocationListItem key={index} LTPMerchantId={item.LTPMerchantId} ChaseOrbitalMerchantId={item.ChaseOrbitalMerchantId} CYBSMerchantId={item.CYBSMerchantId} alert={props.alert} StoreId={item.StoreId} HoursId={item.HoursId} AddressId={item.AddressId} Name={item.Name} Address={item.Address} Address2={item.Address2} City={item.City} State={item.State} PostalCode={item.PostalCode} PhoneNumber={item.PhoneNumber} TaxRate={item.TaxRate} Latitude={item.Latitude} Longitude={item.Longitude} Radius={item.Radius} Sunday={item.Sunday} Monday={item.Monday} Tuesday={item.Tuesday} Wednesday={item.Wednesday} Thursday={item.Thursday} Friday={item.Friday} Saturday={item.Saturday} />
                        }
                    </>
                );
            })}
        </tbody>
    </Table>

标签: reactjs

解决方案


推荐阅读