Open junwen-k opened 2 weeks ago
Hey @junwen-k, thanks for flagging this! I agree that this would be a good change for the React implementation. However, I am not so sure about the other integrations (because I haven't worked intensively with them before).
I don't know if I'll be able to get to this soon, but if you want to shoot a PR I'd appreciate it. No worries if not :)
Recently I've just came across this library, exactly what I was looking for a long time, awesome! However, there is a slight problem with the React (and possibly other frameworks) integration.
Problem
Currently,
useTimescape
is not declarative by default, and to sync the state with external sources, we need to useuseEffect
to handle it manually.Suggestion
To better align with the declarative nature of React,
useTimescape
should be reactive by default, without requiring users to callupdate()
imperatively. For instance:This change aligns well with the React ecosystem API, making it more predictable and declarative.
Remark
Some popular libraries that uses the method that I described
This proposed change could also potentially apply to other frameworks like Solid.
Thank you so much for this awesome library.