# create-react-context **Repository Path**: mirrors_developit/create-react-context ## Basic Information - **Project Name**: create-react-context - **Description**: Polyfill for the proposed React context API - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-08-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # create-react-context > Polyfill for the [proposed React context API](https://github.com/reactjs/rfcs/pull/2) ## Install ```sh yarn add create-react-context ``` You'll need to also have `react` and `prop-types` installed. ## API ```js const Context = createReactContext(defaultValue); // {children} // ... // {value => children} ``` ## Example ```js // @flow import React, { type Node } from 'react'; import createReactContext, { type Context } from 'create-react-context'; type Theme = 'light' | 'dark'; // Pass a default theme to ensure type correctness const ThemeContext: Context = createReactContext('light'); class ThemeToggler extends React.Component< { children: Node }, { theme: Theme } > { state = { theme: 'light' }; render() { return ( // Pass the current context value to the Provider's `value` prop. // Changes are detected using strict comparison (Object.is) {this.props.children} ); } } class Title extends React.Component<{ children: Node }> { render() { return ( // The Consumer uses a render prop API. Avoids conflicts in the // props namespace. {theme => (

{this.props.children}

)}
); } } ```