barelyhuman / barelyhuman/babel-plugin-mutable-react-state

Pass state outside of component scope

オープン
#5 コメント 14 件 リアクション 0 件 担当者 1 名 @barelyhuman が担当を希望しています GitHub で見る
enhancement
主要言語
TypeScript
スター
7
フォーク
0
PR マージ指標
30日以内にマージされた PR はありません

説明

It seems that right now there isn't a convenient way to pass mutable state outside of the component or hook, i.e. return it, pass it to a function or pass it to children.
The only way to get the setter is by creating a closure `val => myState = val`. So if I want to pass around mutable state (read and write) I need to get the setter, then I need to pass both the setter and the value around.
This is a little verbose, and also wherever I pass the mutable state to I'll have to deal with two variables again (value and setter) instead of one.
I think that it could be nice if there was a better way to get the setter and pass around mutable state.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。