2 ms·
The new context API effectively makes variables available globally, but you're still using a separate (explicitly declared) Consumer for each, so you don't have
by crooked-v 9y ago
The new context API effectively makes variables available globally, but you're still using a separate (explicitly declared) Consumer for each, so you don't have any of the basic issues that go with using a single set of globals.
For a very simple example:
import { UserIdConsumer } from '@/contexts'
const ThisComponent = () => (
<div>
User ID: <UserIdConsumer>{value => value}</UserIdConsumer>
</div>
)
export default ThisComponent