-
Notifications
You must be signed in to change notification settings - Fork 8
Hooks with slots #51
base: master
Are you sure you want to change the base?
Hooks with slots #51
Conversation
@bryphe Regarding the above, I am investigating how to trigger a reconciliation after setting the state. Before, we relied on the instance stored in the context but that could potentially be gone now. I have tried a very naive approach where I'd pass all the instance info together with the slots, so that could be picked up transparently: However, this doesn't work because we would need to get the produced instance before it's been produced. There are workarounds but that seems like a wrong path. Instead, I was thinking a couple of things:
Curious to know your thoughts! 🙂 |
</view> | ||
); | ||
let renderCounter = slots => { | ||
let ((count, dispatch), _slots) = slots |> useReducer(reducer, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the example - made it easy to see the impact of the slots
model in the API 👍
Awesome @jchavarri ! So excited to see this come together! 😍 I like the side-by-side approach with
Ah yes - was thinking about this too when I read through the issue. It does seem like it would be challenging to get this right. Agree that it seems like the wrong path.
This seems reasonable to unblock the API. The downside is it would mean a (potential) perf hit, if we end up needing to reconcile more of the tree than before. For example - if you have a large set of rendered elements, and a leaf node calls However, without benchmarks, it's hard to draw a conclusion, and it could very well be a premature optimization in the native world. The nice property of this is that #44 would be fixed with this too, I believe!
I do like the model in If we can't find a good way to do the queued updates - I'm on board with the full reconciliation. This change would bring us much closer to our desired functional component + type-safe hooks API surface, and then we can later focus on the internals, if we decide we need to squeeze more perf out (and when we have proper benchmarking in place, to know exactly where to zero-in). Great progress! |
🚧 🚧 🚧 --- WIP --- 🚧 🚧 🚧 🚧
Implements the ideas in #47.
API changes
The main public API change involves the passing of
slots
instead ofunit
to the inner function insidecreateComponent
, like:TODO:
ReactifyExperiment.re
file, in parallel to the existing one (given there will be a lot of changes)hook('t)
typesSlots
moduleuseReducer
useReducer
useState
useState
useContext
useEffect