Careful switch to the new React Context API.

Pavel Smolin
Apr 8, 2019 · 4 min read
Image for post
Image for post
Photo by Nathan Dumlao on Unsplash
Image for post
Image for post
https://reactjs.org/docs/context.html#legacy-api

Can we update our provider component without breaking the legacy API consumers?

Image for post
Image for post
Photo by Mikhail Vasilyev on Unsplash

Image for post
Image for post
https://gist.github.com/SmolinPavel/3e9be8e0b4b73444d4459708e02ae6e5

This is what we’ll see as an output ⬇

Image for post
Image for post
Image for post
Image for post
https://gist.github.com/SmolinPavel/cd5f87419aa7ad6d69a2335a2818b335

This is the output we gonna achieve ⬇️

Image for post
Image for post

Image for post
Image for post
https://gist.github.com/SmolinPavel/d02fa795b181af8da0ae57198dc20c8f

We do need compatibility! 🔌

Image for post
Image for post
Image for post
Image for post
Photo by Zac Durant on Unsplash

Compare the Market

The people behind comparethemarket.com and the Meerkat App

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app