File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -47,10 +47,9 @@ interface MyComponentProps {
47
47
function MyComponent({ items }: MyComponentProps ) {
48
48
return (
49
49
<ul >
50
- { items .map ((item ) => {
51
- const props = { key: item .id };
52
-
53
- return <li { ... props } >{ item .name } </li >;
50
+ { items .map (({ id , name , ... rest }) => {
51
+ const props = { key: id , ... rest };
52
+ return <li { ... props } >{ name } </li >;
54
53
// ^^^^^^^^^^
55
54
// - Do not use implicit 'key' props.
56
55
})}
@@ -71,7 +70,9 @@ interface MyComponentProps {
71
70
function MyComponent({ items }: MyComponentProps ) {
72
71
return (
73
72
<ul >
74
- { items .map ((item ) => <li key = { item .id } >{ item .name } </li >)}
73
+ { items .map (({ id , name , ... rest }) => {
74
+ return <li key = { id } { ... rest } >{ name } </li >;
75
+ })}
75
76
</ul >
76
77
);
77
78
}
You can’t perform that action at this time.
0 commit comments