react-component / react-component/tree-select
DFS这里是否能调整为尾递归
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 312
- Forks
- 204
- Avg merge
- 37m
- Merged PRs (30d)
- 1
Description
function dig(list: DefaultOptionType[], keepAll: boolean = false): DefaultOptionType[] {
function digRecursive(list: DefaultOptionType[], result: DefaultOptionType[]): DefaultOptionType[] {
if (list.length === 0) {
return result;
}
const dataNode = list[0];
const children = dataNode[fieldChildren];
const match = keepAll || filterOptionFunc(searchValue, fillLegacyProps(dataNode));
const childList = dig(children || [], match);
if (match || childList.length) {
result.push({
...dataNode,
isLeaf: undefined,
[fieldChildren]: childList,
});
}
return digRecursive(list.slice(1), result);
}
return digRecursive(list, []);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at src/hooks/useFilterTreeData.ts around the linked dig function and inspect how recursive filtering handles children, matches, and result ordering. Determine whether the DFS can be adjusted to tail recursion without changing filtering behavior or returned tree data, then verify the existing project checks for regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100