-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(component): refactor Tree component API to StatefulTree #481
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far. I liked what you did with the hooks and context to clean it up. 👍
df85e5f
to
aeb59b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, good job! I couldn't find any major issues, it's a great example of how to build complex components for the future. Lets get another pair of eyes to look at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks pretty good to me overall, just a couple of questions
BREAKING CHANGE: `Tree` component and now `StatefulTree` with new API changes. See dev docs for new API.
aeb59b3
to
78f7a21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 🥇
Btw did you check the profiler to get an overall feel on the re-rendering performance of this component? Some real usecases for this component might get a bit heavy (eg category trees) |
@rtalvarez I did and it's going to rerender frequently due to the use of the context API. I had some discussions with @deini about this, and the only real solution to circumvent this use a state library (Redux/RxJS/etc.). We may need to find a solution for this for all of our stateful/complex components in the future. I'll keep this PR open a bit longer for comments, and in the meantime I will stress test it with a larger dataset. |
packages/big-design/src/components/StatefulTree/hooks/useSelectable.ts
Outdated
Show resolved
Hide resolved
packages/big-design/src/components/StatefulTree/hooks/useSelectable.ts
Outdated
Show resolved
Hide resolved
packages/big-design/src/components/StatefulTree/hooks/useSelectable.ts
Outdated
Show resolved
Hide resolved
packages/big-design/src/components/StatefulTree/hooks/useVisibleNodes.ts
Outdated
Show resolved
Hide resolved
7ee5e7e
to
5da9387
Compare
5da9387
to
1480c89
Compare
What
Refactors
Tree
component to be a more internal component and adds a newStatefulTree
component.Why
The old
Tree
API dealt with a lot of the state management and caused use usage issues:Tree
component due to some state management requirements.onClick
handlers were being requested for certain DOM interactions.Notes
Tree
component anymore until we find we need more granular usages (async node fetches, complex node manipulation, etc...). Until that point in time, you should be usingStatefulTree
.Tree
component is now in a good state that we can add drag-n-drop functionality. This functionality will be for another PR.ping @bigcommerce/frontend