You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
react clone the same item form another list , and the item's key is repeat? #182
In my case, I'm cloning items from options (list 1) to canvas (list 2). I only want to update the canvas and not the options. For cloning and creating new ids for the options, I did the following for the options list
set the list prop as a state
setList to empty function so I can update the list items manually
trigger updating the list items using onEnd hook to update the ids
<ReactSortable
list={optionsList}
setList={() => {}}
// After dropping, update the ids of options in list 1
// This is done to make id unique for dropped elements by updating the ids in list 1
onEnd={this._onDrop}
{...sortableOptions}
group={{
name: 'options',
pull: 'clone' as 'clone',
put: false,
}}
>
In my case, I'm cloning items from options (list 1) to canvas (list 2). I only want to update the canvas and not the options. For cloning and creating new ids for the options, I did the following for the options list
set the list prop as a state
setList to empty function so I can update the list items manually
trigger updating the list items using onEnd hook to update the ids
<ReactSortable
list={optionsList}
setList={() => {}}
// After dropping, update the ids of options in list 1
// This is done to make id unique for dropped elements by updating the ids in list 1
onEnd={this._onDrop}
{...sortableOptions}
group={{
name: 'options',
pull: 'clone' as 'clone',
put: false,
}}
>
In my case, I'm cloning items from options (list 1) to canvas (list 2). I only want to update the canvas and not the options. For cloning and creating new ids for the options, I did the following for the options list
set the list prop as a state
setList to empty function so I can update the list items manually
trigger updating the list items using onEnd hook to update the ids
<ReactSortable
list={optionsList}
setList={() => {}}
// After dropping, update the ids of options in list 1
// This is done to make id unique for dropped elements by updating the ids in list 1
onEnd={this._onDrop}
{...sortableOptions}
group={{
name: 'options',
pull: 'clone' as 'clone',
put: false,
}}
>
it's complicated
Update the id of the original list items after cloning.
Activity
U-DI-Page commentedon Sep 28, 2020
gregg-cbs commentedon Apr 14, 2021
@FourPig
prefix your key with a property that is specific to that list?
AbhisheshPradhan commentedon Jul 7, 2021
In my case, I'm cloning items from options (list 1) to canvas (list 2). I only want to update the canvas and not the options. For cloning and creating new ids for the options, I did the following for the options list
Ashkur commentedon Jul 7, 2021
Same thing. Have you solve it?
U-DI-Page commentedon Jul 12, 2021
clone tow items to one list, the ids still will duplicate
U-DI-Page commentedon Jul 12, 2021
acturally not
U-DI-Page commentedon Jul 12, 2021
it's complicated
AbhisheshPradhan commentedon Jul 12, 2021
Update the id of the original list items after cloning.