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

Pass state outside of component scope

Đang mở
#5 14 bình luận 0 reaction 1 người được giao Được @barelyhuman nhận Xem trên GitHub
enhancement
Ngôn ngữ chính
TypeScript
Star
7
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.