faceyspacey / rfr-demo-mike

Created with CodeSandbox
https://codesandbox.io/s/github/faceyspacey/rfr-demo-mike
1 stars 0 forks source link

Grok-talk on RFR #1

Open oristian opened 2 years ago

oristian commented 2 years ago

This is a pretty slick setup and I can see why it became popular. Like many elegant solutions, there can be more than meets the eye, so I want to make sure I'm really grokking this before going back to working on the useReducer setup.

In the case of the existing videos in the demo, we're putting the slug as a key directly on the state. With multiple models, we should be keying top-level by the model, right? and then the slug keys under that? And I'm really trying to wrap my head around what depth we want at each pass of the reducers. Like what I'm hearing you say for the normalization we're attempting in SKINS, we want to return just slugs (or in our case userIds) for a list of people, but then the detail page takes that key from state and hydrates the rest of the data when requested.

I'm confused about line 7 of the videosHash reducer. We return 'video' to the accumulator and return the full accumulator into the state, but it's unclear why we're doing those and then also setting state[video.slug] = video - isn't that a violation of the immutability principle? I'm getting close to getting this, just need a couple more passes to understand this architecture completely.

faceyspacey commented 2 years ago

Can u #link the lines in question