This recipe provides a collection of codemods to help you migrate your codebase to Valtio v2. These codemods are designed to streamline the transition process by automating common code transformations due to behavioral changes in Valtio v2.
Codemods Included
The following codemods are included in this recipe:
-
Proxy Function Behavior Update
Updates instances of proxy(obj) to use deepClone to ensure objects are deeply copied as in Valtio v1. This adjustment is necessary due to the change from a pure function in v1 to an impure function in v2 that modifies the original object. -
useSnapshot Behavior Adaptation
Modifies the usage of useSnapshot() to be compatible with recent changes for better optimization with useMemo and the upcoming React compiler. This includes wrapping snapshot data with use() to ensure compatibility and performance.