Overview
React Apple Tree is an updated version of the popularreact-sortable-tree library, modernized to support React 18+, updated dependencies, and improved TypeScript types. This guide will help you migrate your existing react-sortable-tree implementation to React Apple Tree.
Why Migrate?
The originalreact-sortable-tree library is no longer actively maintained. React Apple Tree provides:
- React 18+ Support: Full compatibility with the latest React features
- Updated Dependencies: Modern versions of react-dnd (v16) and react-window
- TypeScript Improvements: Better type definitions and TypeScript support
- Active Maintenance: Regular updates and bug fixes
- Same Core API: Minimal breaking changes to ease migration
What’s Different
Updated Dependencies
React Apple Tree uses modern versions of its core dependencies:react-dndv16+ (previously used older versions)react-windowinstead ofreact-virtualizedfor better performance- React 18.3+ and React DOM 18.3+ as peer dependencies
styled-componentsv6+ as a peer dependency
Features Not Yet Implemented
Some features fromreact-sortable-tree are marked as not yet implemented:
- Custom Themes: The
themeprop is not fully implemented - Custom Node Content Renderer: The
nodeContentRendererprop - Custom Placeholder Renderer: The
placeholderRendererprop
API Changes
TherowHeight prop documentation references “react-sortable-tree” in the description but functions the same way in React Apple Tree.
Migration Steps
Update Package Dependencies
Remove the old Ensure your project meets the peer dependency requirements:
react-sortable-tree package and install React Apple Tree:- React ^18.3.1
- React DOM ^18.3.1
- styled-components ^6.1.13
Update Import Statements
Replace all imports from After:
react-sortable-tree with the new package name:Before:React Apple Tree uses styled-components internally, so you don’t need to import a separate CSS file.
Update Helper Function Imports
Helper functions are exported the same way:Before:After:All helper functions remain available and work identically.
Handle Custom Themes (If Applicable)
If you were using the Combine with custom CSS for full styling control.
theme prop with a custom theme package:Temporary workaround:
Use generateNodeProps to add custom styling and className props to achieve similar theming:Update DnD Context (If Using Custom Context)
If you were providing your own react-dnd context, use the named export:Before:After:
Common Gotchas
Styled Components Peer Dependency
React Apple Tree requiresstyled-components as a peer dependency. If you’re not already using it in your project, you’ll need to install it:
CSS Import No Longer Needed
Unlikereact-sortable-tree, you don’t need to import a separate CSS file. Remove any imports like:
TypeScript Types
React Apple Tree has improved TypeScript support. If you’re using TypeScript, you may need to update type imports:React Virtualized → React Window
Internally, React Apple Tree usesreact-window instead of react-virtualized. The prop reactVirtualizedListProps still exists for compatibility, but you’re now passing props to the react-window List component.
Complete Migration Example
Here’s a full before/after comparison: Before (react-sortable-tree):Benefits of Migrating
Modern React Support
Full compatibility with React 18 features including concurrent rendering and automatic batching
Better Performance
Uses react-window for improved virtualization performance with large trees
Active Maintenance
Regular updates, bug fixes, and community support
TypeScript Ready
Enhanced type definitions for better development experience
Need Help?
If you encounter issues during migration:- Check the GitHub repository for known issues
- Review the Storybook examples for implementation patterns
- Open an issue on GitHub if you find bugs or missing features
Next Steps
API Reference
Explore all available props and configuration options
Helper Functions
Learn about data manipulation utilities
Examples
See practical implementation examples
Styling
Customize the appearance of your tree