
Migrating to React’s New Context API - stablemap
https://blog.kentcdodds.com/migrating-to-reacts-new-context-api-b15dc7a31ea0
======
hazza1
React used to be so clean and readable - what happened?

It's great these abstractions exist but for me I want a framework where I
don't need to think about them. Vue comes closest to the original feeling I
got when starting out with React.

~~~
dustingetz
Real functional languages have "lexical scope" and "dynamic scope", both are
necessary for proper functional programming. React.js "functions" don't
evaluate depth-first like a traditional call stack, but rather "breadth first"
(because it offers optimization opportunities) and this breaks dynamic scope,
so these Context hacks are an attempt to get it back. You are right though, I
think React.js is not the end state and the harder we push it the more the
"almost-functional-programming" abstraction is going to leak.

~~~
root_axis
This is totally incorrect. Context has nothing to do with JavaScript scoping
behavior. Directly from the React documentation:

"Context provides a way to pass data through the component tree without having
to pass props down manually at every level."

~~~
dustingetz
That is what dynamic scope _is_ , and javascript doesn't have it, but
ClojureScript does, and React still breaks it.

~~~
root_axis
I'm sorry but you're not making any sense. What does the react context api
have to do with dynamic scoping?

------
bnchrch
I admire the spirit of the post but it seems contrived and hard to grok.

As soon as you go down the state and lifecycle method route my spidy senses
start tingling.

I have yet to see an example on the new context api that wouldn't be clearer
with stateless components + recompose. Perhaps someone could point me to the
advantages?

~~~
notheguyouthink
Can you briefly describe what you mean by recompose? I'm a backend dev tasked
with writing some react, and what I'm using currently is redux+react, but
that's about it. More information would be appreciated so I can research :)

~~~
Vinnl
It's a library :)
[https://github.com/acdlite/recompose](https://github.com/acdlite/recompose)

------
latchkey
Enzyme still needs to support it.

[https://github.com/airbnb/enzyme/issues/1553](https://github.com/airbnb/enzyme/issues/1553)

