3 ms·
I don't know much Clojure, but it sounds like this is exactly the use case that context is meant for. If you were to use dynamic scope, how would the variables
by spicyj 10y ago
I don't know much Clojure, but it sounds like this is exactly the use case that context is meant for.
If you were to use dynamic scope, how would the variables be restored if one of the descendants updated via setState? It doesn't seem to me like it would work.
Also, not sure what "context hacks" you mean or what "web worker call stack serialization" is.
- dustingetz 10y agoI think dynamic scope can work with setState by allocating a new closure that closes over the dynamic vars, aliasing them into lexical scope of the render function. The problem with React Context is that it bypasses the general solution offered at language layer for a react-specific solution, essentially breaking any code written without prior knowledge of React.
- spicyj 10y agoCan you say what changes would be required in React for this to work? I assume that you are asking for parent components to be on the stack when child components render, but that is simply not how React works – you return a description of what you want to render then React calls into the children. How could the parent be on the stack? If you have a concrete suggestion for something we could change in React I'd be happy to chat about it. I'd love to support CLJS better.
- dustingetz 10y ago> but that is simply not how React works ... React calls into the children That's not how function components work, and i can easily imagine how to get lifecycle methods back (including optimizations) on function components
- spicyj 10y agoPlease open an issue with more details about the changes you'd like and tag me in it.