Closed Laxy317 closed 1 year ago
In fact, we can use the useImperativeHandle API, welcome pr
In fact, we can use the useImperativeHandle API, welcome pr
I don't think useImperativeHandle
is useful. The problem is caused by
// PhotoView.tsx
const originRef = useRef<HTMLElement>(null);
if (children) {
return Children.only(cloneElement(children, { ...eventListeners, ref: originRef }));
}
The originRef
will reset the user settings, there doesn't seem to be a way to fix it with useImperativeHandle
.
useImperativeHandle(children?.ref, () => originRef.current);
It works fine. I didn't test it carefully and if there were no bugs I released the version
OK,thanks
I'm using both
react-photo-view
and@dnd-kit/sortable
on the same image, such as :Both of them need to set ref, which cause the drag library invalid. Although I can add a
div
to fix it, but i think there will be a better solution, such as using react-merge-refs