marchaos / react-virtualized-sticky-tree

A React component for efficiently rendering tree like structures with support for position: sticky
MIT License
152 stars 12 forks source link

Any plans of moving to hooks? #18

Closed abidRahim closed 3 years ago

abidRahim commented 4 years ago

Would be more than glad to contribute.

marchaos commented 4 years ago

Yes, I actually wrote up a proposal about what I want to do. I'd be inclined to still use with PureComponent for StickyTree (which is the same as react-window - see https://github.com/bvaughn/react-window/blob/master/src/createListComponent.js) due to performance reasons, but proposed exposing a Context and a hook for accessing the API of StickyTree.

Thoughts welcome.

abidRahim commented 4 years ago

Imo Context API won't be a wise choice for performance reasons, unless Redux is used for the same purpose. On using useContext() and useReducer() hooks for one of my projects, i realized that changing any state in the Context reflects a DOM update on all the other components where Global state has been used, irrespective of the usage of newly updated state in those components.

marchaos commented 4 years ago

I'm aware of that issue, but don't think that would affect performance for this usecase, but the experience I gain with hooks, the more I think PureComponent is probably best in this case. Were you hoping that there would be a set of hooks exposed as part of the API, or just thinking that the library itself would benefit from hook usage?

abidRahim commented 4 years ago

I was hoping, the library itself would benefit from the usage of hooks. Let's say for future updates and code readability purpose.

marchaos commented 3 years ago

Converted to TypeScript, but kept the usage or PureComponent due to performance reasons. It's still compatible to use with hooks - see examples