minop1205 / react-dnd-treeview

A draggable / droppable React-based treeview component. You can use render props to create each node freely.
MIT License
520 stars 69 forks source link

[bug] drag preview node weird when using `React.StrictMode` #107

Closed percy507 closed 2 years ago

percy507 commented 2 years ago

Hi,

Thanks for your work. It's really awesome.

I search lots of react tree components and finally decide use yours.👍

I am use the newest version of react: v18.0.0.

During testing, I find a weird thing in drag preview node.

I am use the fork of your official case locally.

And I am use React.StrictMode as root component. And....I find if remove the strict mode, below behavior will not happened. Hint: don't test in CodeSandbox, because it always in production, so the strict mode will not work.

2022-04-05 17 01 31

minop1205 commented 2 years ago

@percy507 Thanks for the bug report!

We will be releasing version 2 in the near future and will try to include the bug fixes you reported.

Please wait for a while for the official release.

percy507 commented 2 years ago

Thanks.

percy507 commented 2 years ago

@minop1205 Here is a suggest. Enable the official eslint plugin of react hooks may helpful.

percy507 commented 2 years ago

@minop1205 I think I fix the problem by adding the missed deps in react hooks.😂

Here is the PR.

https://github.com/minop1205/react-dnd-treeview/pull/108

minop1205 commented 2 years ago

@percy507 I have tried to confirm this problem locally, but have not been able to reproduce it.

Could you please tell me more about how to reproduce it? Alternatively, a reproducible repository would be helpful.

percy507 commented 2 years ago

Which react version you are using? Mine is the newest verison: v18.

And I think the problem happens may because of the new features of React.StrictMode in v18.

You can test it again. If failed reproduce again, please send me your local test-project. (percymong@163.com)

minop1205 commented 2 years ago

Thank you for your contribute!

Merged: https://github.com/minop1205/react-dnd-treeview/pull/108

minop1205 commented 2 years ago

BTW, the reason I could not reproduce this was because I was not using createRoot and was running in React v17 mode.

When I used createRoot, I was able to reproduce it.

percy507 commented 2 years ago

That's right.