@@ -49,11 +49,14 @@ export class ReactSortable<T extends ItemInterface> extends Component<
4949 this.ref = createRef<HTMLElement>();
5050
5151 // make all state false because we can't change sortable unless a mouse gesture is made.
52- const newList = props.list.map((item) => ({
53- ...item,
54- chosen: false,
55- selected: false,
56- }));
52+ const newList = [...props.list];
53+
54+ newList.forEach((item: T) => {
55+ Object.assign(item, {
56+ chosen: false,
57+ selected: false,
58+ });
59+ })
5760
5861 props.setList(newList, this.sortable, store);
5962 invariant(
@@ -235,10 +238,14 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
235238 const otherList = [...store.dragging!.props.list];
236239 const customs = createCustoms(evt, otherList);
237240 removeNodes(customs);
238- const newList = handleStateAdd(customs, list, evt, clone).map((item) => ({
239- ...item,
240- selected: false,
241- }));
241+
242+ const newList = handleStateAdd(customs, list, evt, clone)
243+
244+ newList.forEach((item) => {
245+ Object.assign(item, {
246+ selected: false,
247+ });
248+ });
242249 setList(newList, this.sortable, store);
243250 }
244251
@@ -289,7 +296,11 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
289296 }
290297
291298 // remove item.selected from list
292- newList = newList.map((item) => ({ ...item, selected: false }));
299+ newList.forEach((item: T) => {
300+ Object.assign(item, {
301+ selected: false,
302+ });
303+ })
293304 setList(newList, this.sortable, store);
294305 }
295306
@@ -314,10 +325,9 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
314325 const { list, setList } = this.props;
315326 const newList = list.map((item, index) => {
316327 if (index === evt.oldIndex) {
317- return {
318- ...item,
328+ Object.assign(item, {
319329 chosen: true,
320- };
330+ }) ;
321331 }
322332 return item;
323333 });
@@ -328,10 +338,9 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
328338 const { list, setList } = this.props;
329339 const newList = list.map((item, index) => {
330340 if (index === evt.oldIndex) {
331- return {
332- ...item,
341+ Object.assign(item, {
333342 chosen: false,
334- };
343+ }) ;
335344 }
336345 return item;
337346 });
@@ -345,7 +354,12 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
345354
346355 onSelect(evt: MultiDragEvent): void {
347356 const { list, setList } = this.props;
348- const newList = list.map((item) => ({ ...item, selected: false }));
357+ const newList = [...list];
358+ newList.forEach((item) => {
359+ Object.assign(item, {
360+ chosen: false,
361+ });
362+ });
349363 evt.newIndicies.forEach((curr) => {
350364 const index = curr.index;
351365 if (index === -1) {
@@ -362,7 +376,12 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
362376
363377 onDeselect(evt: MultiDragEvent): void {
364378 const { list, setList } = this.props;
365- const newList = list.map((item) => ({ ...item, selected: false }));
379+ const newList = [...list];
380+ newList.forEach((item) => {
381+ Object.assign(item, {
382+ chosen: false,
383+ });
384+ });
366385 evt.newIndicies.forEach((curr) => {
367386 const index = curr.index;
368387 if (index === -1) return;
0 commit comments