Add a reset history method to useStateWithHistory
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react, typescript
- 領域
- frontend
調査の方向性
Start by locating the TypeScript implementation and tests for useStateWithHistory, then compare its API with useUndoable's resetInitialState. Add a reset method that accepts the new state, makes it the sole history entry, and leaves rewinding unable to reach the previous initial value; update or add tests for the reset behavior.
索引モデルが issue の本文から書いたものです。
説明
Is your feature request related to a problem? Please describe.
useUndoable has a great summary of why resetting state on useStateWithHistory is useful. I set my state to the response of a network request and want to prevent the user being able to rewind history to the initial value set before the request had finished.
Describe the solution you'd like
Add a method to useStateWithHistory that follows the API of useUndoable's resetInitialState, where it takes in a param to set the state to and clears the history.
Describe alternatives you've considered
There are two alternatives I've been using:
- using useUndoable instead of this library (but it doesn't work for deeply nested objects and is an additional dependency)
- Manually extending the useStateWithHistory myself to include this method. The method is really easy to add:
const resetInitialState = useCallback(
(newInitialState: IHookStateInitAction<S>) => {
innerSetState(newInitialState as S);
history.current = [newInitialState as I];
historyPosition.current = 0;
},
[],
);
This seems to have been requested already in https://github.com/streamich/react-use/issues/1386 but I'm re-raising here because:
I believe the interface of useUndoable is relevant, I'm providing a proposed solution, and that issue has been open for over 2 years.
If approved i'd even be happy to raise a PR myself.
Thanks!
- 主要言語
- TypeScript
- スター
- 44k
- フォーク
- 3.3k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
streamich/react-use のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
Add Generic Fn for useDebounce対応中かも @itsmejay80 が 191 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
-
useVideo.story.tsx - sampleVideo can not be loaded再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
-
useSlider: event callbacks are not updated対応中かも @erykpiast が 1838 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
streamich/react-use の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
jessepollak/home#2223 ·
メンテナーはふだん 1 日以内に返信
-
grep fixture corpus test follows the corpus's loop symlink under the receipt runner (fails on main)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
code-yeongyu/senpi#3756 ·
メンテナーはふだん 1 日以内に返信
-
org:external package:deepagents priority:triage topic:memory topic:middleware type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
langchain-ai/deepagents#7059 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
osmlab/name-suggestion-index#12992 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
hemilabs/ui-monorepo#2506 ·
メンテナーはふだん 1 日以内に返信