A CLI tool to analyze a React project and generate a component tree in Markdown format for visualization with Markmap.
- Automatically detects React components in a project.
- Generates a structured Markdown representation of the component hierarchy.
- Allows filtering of external library components.
- Supports scanning specific directories.
npm install -g react-component-tree-generator
react-tree [directory] [options]
-
directory
(optional) - The root directory of your React project (default: current directory.
).
-
--ignore-libs <libs...>
- Ignore components imported from specified libraries. -
--project-only
- Only include components defined within the project. -
--in <dirs...>
- Restrict scanning to specific directories (relative to the project root).
react-tree ./my-react-app
react-tree ./my-react-app --ignore-libs react-bootstrap antd
react-tree ./my-react-app --in src/components src/pages
react-tree ./my-react-app --project-only
The script generates a Markdown file componentsTree.mm.md
in the following format:
---
title: Component Tree
markmap:
colorFreezeLevel: 4
---
## Layout
- Navbar
- Home
- SlideShowA
- SlideShowB
- PersonalDetails
- CardContainerA
- Card
- CardContainerB
- Card
You can visualize this file using Markmap.
This project is licensed under the MIT License.