beizhedenglong / reactablejs

A react high-order component for interact.js(drag and drop, resizing and multi-touch gestures).
https://beizhedenglong.github.io/reactablejs/
MIT License
64 stars 8 forks source link

Stale react state #9

Closed MarkDGithub closed 2 years ago

MarkDGithub commented 2 years ago

Hi, I appreciate the work you have done with this project and I would like to ask if I could help you with the library. One of the issues which I found is that the event handlers use a stale React state. I know that there is a workaround by using useRef(). However, this gets complicated when using Redux and leads to duplicate data. I solved this for the events by refactoring the code to React hooks. Meanwhile I also updated the npm dependancies. You can find my changes here: npm-updates-and-using-react-hooks I could create a pull request.

beizhedenglong commented 2 years ago

PR is welcome. BTW, can give an example to demonstrate this problem?

MarkDGithub commented 2 years ago

can give an example to demonstrate this problem?

I recreated and simplified the problem here . The stale counter is just a simplification. This is where I update the Redux store in my real application. PR: #10

beizhedenglong commented 2 years ago

I see. I checked out you branch, it seems has some issues with the drag demo

https://user-images.githubusercontent.com/12963675/146944298-eabe945a-ec29-4ab6-a3e1-1b07c93fff97.mov

MarkDGithub commented 2 years ago

it seems has some issues with the drag demo

I can't reproduce this issue, I'm using respectively the following commands: yarn install, yarn build-storybook, yarn storybook

https://user-images.githubusercontent.com/20031139/146976777-5545b6e7-6897-4ea0-8720-9a87227a74f1.mov

MarkDGithub commented 2 years ago

I also tried if the problem occurs after cloning the project again and checking out the new branch (so basically a blank sheet). But the problem still doesn't occur.

beizhedenglong commented 2 years ago

I figured it out. It was caused by one of my chrome extensions.

MarkDGithub commented 2 years ago

Thanks for accepting. Will the npm package be updated automatically?

beizhedenglong commented 2 years ago

I just published it to npm. try toreinstall the package