{"id":15759492,"url":"https://github.com/henribeck/react-context-subscriber","last_synced_at":"2026-05-05T07:33:12.705Z","repository":{"id":65473159,"uuid":"127753473","full_name":"HenriBeck/react-context-subscriber","owner":"HenriBeck","description":"A HOC for subscribing to the new React Context. Useful for class components.","archived":false,"fork":false,"pushed_at":"2018-08-18T09:42:40.000Z","size":664,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T21:37:44.645Z","etag":null,"topics":["context","hoc","react","react-context","react16","reactjs","subscription"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HenriBeck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-02T12:30:41.000Z","updated_at":"2018-08-18T09:42:38.000Z","dependencies_parsed_at":"2023-01-25T03:05:14.169Z","dependency_job_id":null,"html_url":"https://github.com/HenriBeck/react-context-subscriber","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenriBeck%2Freact-context-subscriber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenriBeck%2Freact-context-subscriber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenriBeck%2Freact-context-subscriber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenriBeck%2Freact-context-subscriber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HenriBeck","download_url":"https://codeload.github.com/HenriBeck/react-context-subscriber/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246443536,"owners_count":20778249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["context","hoc","react","react-context","react16","reactjs","subscription"],"created_at":"2024-10-04T10:20:33.931Z","updated_at":"2026-05-05T07:33:12.666Z","avatar_url":"https://github.com/HenriBeck.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-context-subscriber\n\n[![npm](https://img.shields.io/npm/v/react-context-subscriber.svg)](https://www.npmjs.com/package/react-context-subscriber) ![Maintenance](https://img.shields.io/maintenance/yes/2018.svg) ![npm](https://img.shields.io/npm/l/react-context-subscriber.svg) ![David](https://img.shields.io/david/HenriBeck/react-context-subscriber.svg) [![CircleCI](https://circleci.com/gh/HenriBeck/react-context-subscriber.svg?style=svg)](https://circleci.com/gh/HenriBeck/react-context-subscriber)\n\nA Higher-order-Component for subscribing to the new React Context.\nThis will make the context available in the lifecycle methods etc.\n\n### Installation\n\n```sh\nyarn add react-context-subscriber\n```\n### Usage\n\n\u003e This doesn't actual need to be the new React Context.\n\u003e It will work with any Consumer that accepts a function as it's child.\n\u003e For example this will work with [react-create-context](https://github.com/jamiebuilds/create-react-context) too.\n\n```js\nimport React from 'react';\nimport subscribeToContext from 'react-context-subscriber';\n\n// Again, this doesn't need to be the new React Context\nconst Context = React.createContext('context');\n\nclass Component extends React.Component {\n  render() {\n    return this.props.context;\n  }\n}\n\nexport default subscribeToContext(Context.Consumer)(Component);\n```\n\n#### Change the prop name of the context\n\nSimply pass to the HoC a string as the second argument.\nThe default prop name is `context`.\n\n```js\nimport React from 'react';\nimport subscribeToContext from 'react-context-subscriber';\n\n// Again, this doesn't need to be the new React Context\nconst Context = React.createContext('context');\n\nclass Component extends React.Component {\n  render() {\n    return this.props.context;\n  }\n}\n\nexport default subscribeToContext(Context.Consumer, 'propName')(Component);\n```\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenribeck%2Freact-context-subscriber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenribeck%2Freact-context-subscriber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenribeck%2Freact-context-subscriber/lists"}