question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switch to new context API

See original GitHub issue

React will soon introduce a new API for context. We should start using the latest version of react-broadcast, which is a polyfill of that API. When we first built styled-components we inlined an implementation of react-broadcast to avoid introducing an unnecessary layer of components, so that needs to be removed too.

PRs very welcome! 💯

/cc @gaearon

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:19 (13 by maintainers)

github_iconTop GitHub Comments

5reactions
gaearoncommented, Feb 21, 2018

We should start using the latest version of react-broadcast, which is a polyfill of that API.

FWIW I’m not confident that would work great because react-broadcast will be more heavyweight at runtime than the new context API, and in case of styled-components that overhead is shared by every component.

Maybe it would be better to cut a new major with 16.3+ compatibility.

4reactions
TrySoundcommented, Jan 29, 2018

There’s also ready to go polyfill create-react-context

Read more comments on GitHub >

github_iconTop Results From Across the Web

Context API in React! | Switch to it NOW! - DEV Community ...
This post covers how you can use the Context API in React. ... Create and export another variable/component called MainProvider , where we ......
Read more >
Migrating to React's New Context API - Kent C. Dodds
Because of this significant change, I'm making an update to my advanced component patterns course on egghead.io to use the new API rather ......
Read more >
Context - React
Context provides a way to pass data through the component tree without having to pass props down manually at every level. In a...
Read more >
Get to Know React's New Context API - DigitalOcean
In this tutorial we will demonstrate using React's Context API to handle passing state between many layers of components.
Read more >
From Redux to the Context API: A Practical Migration Guide
Let's migrate a React application built with Redux to the Context API and see how it looks like.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found