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

Expose treeItem internals #313

Closed
keegan-lillo opened this issue Jan 3, 2024 · 1 comment
Closed

Expose treeItem internals #313

keegan-lillo opened this issue Jan 3, 2024 · 1 comment
Assignees

Comments

@keegan-lillo
Copy link

Is your feature request related to a problem? Please describe.
I've been creating a solution to #263 for my own usage and I managed to get something that works pretty well using a few custom renderers, however I have had to reach into the lib directory and import TreeItem.

import { TreeItem } from 'react-complex-tree/lib/cjs/treeItem/TreeItem'

This isn't a huge issue, however I have had to also update all my other imports to use 'react-complex-tree/lib/cjs' since NextJS/Webpack switches between the CJS and ESM versions depending on client/server builds so React context gets lost.

Describe the solution you'd like
Expose TreeItem or useTreeItemRenderContext to the main package. If they are still "unstable", maybe expose them under a __UNSTABLE constant?

// src/index.ts
import { useTreeItemRenderContext } from './treeItem/useTreeItemRenderContext';
import { TreeItem } from './treeItem/TreeItem';

export * from './controlledEnvironment/ControlledTreeEnvironment';
export * from './tree/Tree';
export * from './uncontrolledEnvironment/UncontrolledTreeEnvironment';
export * from './uncontrolledEnvironment/StaticTreeDataProvider';
export * from './types';
export * from './renderers';

export const __UNSTABLE = {
  useTreeItemRenderContext,
  TreeItem,
};

Describe alternatives you've considered

  • Import directly from 'react-complex-tree/lib/cjs'

Additional context

@lukasbach
Copy link
Owner

Hey, thanks for the suggestion. The TreeItem component isn't actually that unstable, but I'd still consider it an implementation detail that doesn't make sense to expose directly. But I did expose it as part of a "INTERNALS" export that I added now in v2.3.3, similar to what you suggested. Note that I renamed TreeItem to TreeItemElement to avoid confusion with the type of the same name TreeItem, which refers to the data field.

For the hook you mentioned, I can actually see realistic use cases for that and it makes more sense to use in normal applications, so I exposed the hook also in v2.3.3 as normal export.

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

No branches or pull requests

2 participants