daangn / daangn/stackflow

Question: How is the stack lifecycle (`activities` array) intended to be managed?

Open
#631 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1k
Forks
114
Avg merge
3m
Merged PRs (30d)
2

Description

According to the official documentation, the useStack() hook can be used to access the stack state within UI components. However, when examining the activities array returned from useStack(), I noticed that its length increases by one each time the push or replace functions are called, and does not decrease when the pop function is invoked.

It is true that by checking properties such as transitionState, isTop, or isActive, one can determine which screen the user is currently viewing. Still, if the user repeatedly performs push or replace operations, the array continues to grow regardless of what the user actually sees. Intuitively, in scenarios such as when the user has finished navigating and returned to the root activity, one would expect the array to reset. Without some form of cleanup, the length of the array could, at least in theory, grow without bound.

As far as I know, Stackflow does not currently provide an API to reset or trim the stack state array in this manner. Of course, since Stackflow is obviously well-designed to be easily extended and customized through plugins, I imagine it would not be very difficult for me to implement additional functionality by myself if needed. That said, before proceeding, I would like to confirm whether my understanding aligns with the framework’s intended design. Or am I perhaps misunderstanding how the lifecycle of the stack is meant to be managed?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the official documentation for useStack() and the activities lifecycle around push, replace, and pop. Determine whether the array is intentionally append-only and whether returning to the root should trim it or remain observable through transitionState, isTop, and isActive. Done means documenting the intended behavior or defining a clear reset/trim requirement.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, mobile-dev
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.