Socket
Socket
Sign inDemoInstall

@asphalt-react/context

Package Overview
Dependencies
3
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @asphalt-react/context

share context among asphalt components


Version published
Weekly downloads
153
increased by2%
Maintainers
3
Install size
7.72 kB
Created
Weekly downloads
 

Readme

Source

@asphalt-react/context

⚠️ Designed for Asphalt React component packages. Use at your own risk, if using externally.

A package which contains a React context which is to be shared among asphalt components.

Why

There are use cases, where two different packages need to communicate. In such cases, rather than creating inter-package dependency, they both can import @asphalt-react/context and use Provider and Consumer from it.

Usage

Provider

import Component2 from "@asphalt-react/component"
import { Provider } from "@asphalt-react/context"

export default (Component = () => (
  <Provider value={{ id: 1 }}>
    <Component2 />
  </Provider>
))

Consumer

import { Provider } from "@asphalt-react/context"

export default (Component2 = () => (
  <Consumer>{({ id }) => <span>{id}</span>}</Consumer>
))

Keywords

FAQs

Last updated on 26 Jul 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc