-
teaful is a new library for react. minimal and easy to use. i have nothing to do with it. just wondering. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
it looks like a proxy store. zustand state is plain javascript object notation (json). if i have to deal with raw data and i want a non-proxy app backbone i'd pick zustand over anything that has proxies. if i need proxies i usually pick valtio. it seems to me that a proxy state with a zustand-like api surface is unnecessary (get/set api, selectors). at least @dai-shi has proven with valtio that it can be more reduced than basing proxy on traditional flux api. it uses a single hook |
Beta Was this translation helpful? Give feedback.
-
I admire the work of Zustand and Valtio. In fact, at the time I made Teaful open-source I didn't know them. I personally don't like the comparison between library X and Z. Surely, depending on the project, one or the other may be more interesting. Teaful is still in version 0.x and it is necessary to evolve it with sense and I am open to listening to suggestions and proposals for version 1.0. The goals of Teaful are to be a tiny library (-1kb), easy to use (similar to useState in React), and powerful (only rerendering the components that use the part of the store they consume). The proxy is used as an intermediary between the state (in JSON) and the component consumption. const [price, setPrice] = useStore.cart.price()
console.log(typeof price) // number
console.log(typeof setPrice) // function It does not return a proxy. It uses a proxy to subscribe to the JSON state portion ( It is a different approach. The approach is more immutability to make it closer to the useState, and not mutating the state through a proxy like Valtio. |
Beta Was this translation helpful? Give feedback.
it looks like a proxy store. zustand state is plain javascript object notation (json). if i have to deal with raw data and i want a non-proxy app backbone i'd pick zustand over anything that has proxies. if i need proxies i usually pick valtio. it seems to me that a proxy state with a zustand-like api surface is unnecessary (get/set api, selectors). at least @dai-shi has proven with valtio that it can be more reduced than basing proxy on traditional flux api. it uses a single hook
useSnapshot
and now you can pick and mutate state.