moveable
moveable copied to clipboard
React Moveable ref set target with setState not working
Hi, in React I have the moveable ref, when mousedown to the component I use setState to set the target but it not affect:
The codesanbox:
https://codesandbox.io/embed/vibrant-mestorf-j5byc1?fontsize=14&hidenavigation=1&theme=dark
@ngocducdim
sorry but you can't use moveable.setState
You must use the target={target} prop.
@ngocducdim
I'll add waitToChangeTarget method for dragStart.
moveable.waitToChangeTarget().then(() => {
moveable.dragStart(e);
});
setTarget(target);
@ngocducdim
moveable's new version is released.
waitToChangeTarget method is added.
moveable.waitToChangeTarget().then(() => {
moveable.dragStart(e);
});
setTarget(target);
Update the sandbox it work, but when integrate with my project
moveable.waitToChangeTarget().then(() => {
console.log('updated');
});
the console never log the 'updated', maybe because I use Selecto package, thanks you anyway for the work
@ngocducdim
call setTargets after waitToChangeTarget
I have call setTargets, but still can't work, my small part of the code:

- Try to select:

- The console output:

@ngocducdim
Okay. I'll check it again.
@ngocducdim
0.38.2 was released. check it again.
It works now, thank you for your fix!