Socket
Socket
Sign inDemoInstall

create-react-context

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-react-context

Polyfill for the proposed React context API


Version published
Weekly downloads
838K
decreased by-21.42%
Maintainers
1
Weekly downloads
 
Created

What is create-react-context?

The create-react-context package is a polyfill for the React context API for React versions below 16.3. It allows you to create a context object which can be used to pass data through the component tree without having to pass props down manually at every level.

What are create-react-context's main functionalities?

Creating Context

This feature allows you to create a new context object. You can set a default value that can be used when a component does not have a matching Provider above it in the tree.

{"const MyContext = createReactContext(defaultValue);"}

Provider Component

The Provider component is used to set the value of the context to be accessible by all components that are its descendants.

{"<MyContext.Provider value={/* some value */}>{/* some child components */}</MyContext.Provider>"}

Consumer Component

The Consumer component is used to read the current context value, provided by the nearest matching Provider above it in the tree.

{"<MyContext.Consumer>{value => /* render something based on the context value */}</MyContext.Consumer>"}

Other packages similar to create-react-context

Keywords

FAQs

Package last updated on 05 Jun 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc