Skip to content
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

Merged
merged 5 commits into from
Dec 17, 2020

Conversation

chanceaclark
Copy link
Contributor

@chanceaclark chanceaclark commented Dec 10, 2020

What

Refactors Tree component to be a more internal component and adds a new StatefulTree component.

Why

The old Tree API dealt with a lot of the state management and caused use usage issues:

  1. The old API wasn't very "React-y", in the sense that you couldn't re-render nodes based on any API updates.
  2. Focus on the page went directly to the Tree component due to some state management requirements.
  3. onClick handlers were being requested for certain DOM interactions.

Notes

  • We are not going to be exposing the 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 using StatefulTree.
  • Hopefully the Tree component is now in a good state that we can add drag-n-drop functionality. This functionality will be for another PR.
BREAKING CHANGE:
`Tree` component and now `StatefulTree` with new API changes.
See dev docs for new API.

ping @bigcommerce/frontend

Copy link
Contributor

@jorgemoya jorgemoya left a 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. 👍

packages/big-design/src/components/Tree/types.ts Outdated Show resolved Hide resolved
@chanceaclark chanceaclark changed the title refactor(components): refactor Tree component API to StatefulTree refactor(component): refactor Tree component API to StatefulTree Dec 14, 2020
@chanceaclark chanceaclark marked this pull request as ready for review December 14, 2020 21:30
@chanceaclark chanceaclark requested a review from a team as a code owner December 14, 2020 21:30
@chanceaclark chanceaclark requested a review from a team December 14, 2020 21:31
Copy link
Contributor

@jorgemoya jorgemoya left a 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.

packages/docs/pages/StatefulTree/StatefulTreePage.tsx Outdated Show resolved Hide resolved
Copy link
Member

@rtalvarez rtalvarez left a 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

Copy link

@BC-YIvashchenko BC-YIvashchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 🥇

@rtalvarez
Copy link
Member

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)

@chanceaclark
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants