Values of nested objects become undefined
#670
octet-stream
started this conversation in
General
Replies: 1 comment 3 replies
-
Hi, thanks for reporting. Would you be able to drill down and create a very small reproduction with https://codesandbox.io/s/react-new ? (without next.js)
That's very helpful. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Tested valtio versions:
1.9.0
,1.10.0
,1.10.1
,1.10.2
. This behaviour first appears in1.10.1
.In my example Next.js app, starting from the
valtio@1.10.1
, every value of nested proxy object becomesundefined
, while the keys copied just fine. In the app I use React Context to simplify access to the store: For eachContext.Provider
provided with the page data, a newproxy
is created. The main page has a collection of objects within that main state object, for which I also create a newproxy
usingContext.Provider
. For each created nested object state, I see the keys of that object as expected, but then all the values are gone and replaced withundefined
.Steps to reproduce
docker compose
(notdocker-compose
).git clone -b valtio-issue --single-branch git@github.com:octet-stream/next-mikro-orm-trpc-template.git valtio-issue && cd valtio-issue
npm run demo --build
command. It will pull MySQL image used by the app, then build the app itself and start it. After you've done with the demo, pressCtrl+C
to stop the app and MySQL.3.1. On Linux/Windows you might need to setup the app manually: install dependencies
npm install
3.2 Run
npm run test:compose-up
to pull mysql image and run it3.3 Run
npm run build && npm run start
to build and start the app (or runnpm run dev
to start the app in development mode).3.4 Once you finished with the demo, run
npm run test:compose-down
to stop MySQLhttp://localhost:3000
, then create a new note. After the note is created, you will see that no data is presented within cards. Then if you refresh the page, the result will be the same: You'll see empty note card(s).Screenshot with the result
Also, if you open browser DevTools console, you can see that
notes
object has values, as expected. Even for nested objects withinnotes.items
collection. But then in store created for each individual object from this collection the values areundefined
.Check List
Please do not ask questions in issues.
Please include a minimal reproduction.
Beta Was this translation helpful? Give feedback.
All reactions