Skip to content

Commit

Permalink
Refactor UI state: rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanchrobot committed Feb 18, 2024
1 parent 4628c32 commit 3393d66
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions assets/tree/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default function App({ tree }) {
}

function TreeNode({ node, level }) {
const [expanded, setExpanded] = useState(shouldAutoExpand(node, level));
const [isExpanded, setIsExpanded] = useState(shouldAutoExpand(node, level));

function handleExpandClick() {
if (node.children) {
setExpanded(!expanded);
setIsExpanded(!isExpanded);
}
}

Expand All @@ -36,21 +36,21 @@ function TreeNode({ node, level }) {
>
<div className="mr-0.5 inline-block w-[2ch] flex-shrink-0">
{node.children &&
(expanded ? (
(isExpanded ? (
<RiArrowDownSFill size={20} />
) : (
<RiArrowRightSFill size={20} />
))}
</div>
<div>
{node.children && expanded ? (
{node.children && isExpanded ? (
<TextItems items={node.expanded.prefix} />
) : (
<TextItems items={node.content} />
)}
</div>
</div>
{node.children && expanded && (
{node.children && isExpanded && (
<>
<ol className="m-0 ml-[2ch] block list-none p-0">
{node.children.map((child, index) => (
Expand Down

0 comments on commit 3393d66

Please sign in to comment.