-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Nice lib! I am surprised how little code is needed to work around the problem with React Context API.
One thing that I found missing is the ability to pass a function receiving current value into the setter (just like when using React.useState).
But then I realised this can be done like so:
setRidgeState(state, fn(getRidgeState(state)))and it will work as long as useRidgeState(state) is called in the component
This is a bit awkward and redundant though.
Would an API like this make sense?
useRidgeSubscription(state) // re render on change, no return
state.get() // getter for the value
state.set(...) = // setter for the valueNow there is only one way of getting and setting the state without extra imports needed.
JS getter/setter could be used instead of normal functions.
A loose idea, probably too big of a change anyway.
RichardLindhout and steinathanRichardLindhout and eldadcaspisteinathan
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request