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 {
4747function MyComponent({ items }: MyComponentProps ) {
4848 return (
4949 <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 >;
5453 // ^^^^^^^^^^
5554 // - Do not use implicit 'key' props.
5655 })}
@@ -71,7 +70,9 @@ interface MyComponentProps {
7170function MyComponent({ items }: MyComponentProps ) {
7271 return (
7372 <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+ })}
7576 </ul >
7677 );
7778}
You can’t perform that action at this time.
0 commit comments