Closed Interpause closed 2 years ago
I have once tried with valtio, but proxying any class instances leads unpredictable results. For example, it will proxy Date
, or whatever we don't expect. We could technically make markToTrack
to accept custom function for more control, but I'm not sure if most developers can use it.
it requires the user to recursively mark everything. Doing so, react-tracked is able to track nested class instances within my use case at least.
So, what you did is the expected approach by the design. tbh, I'm surprised you made it work with the current documentation.
Thanks for the feedback. Hope it makes sense.
Yup, thanks
I am using react-tracked to handle the game state of a board game I am making. However, since proxy-compare ignores class instances by default, none of the render optimizations react-tracked offers work.
Currently,
createProxy()
only proxies objects and arrays. This can be fixed by usingmarkToTrack()
on class instances, but if the class contains nested class instances, it requires the user to recursively mark everything. Doing so, react-tracked is able to track nested class instances within my use case at least. Hence, could it be possible to allowcreateProxy()
to also proxy class instances by default? If not, what are the pitfalls of doing so?